Mocha Testing Issue
See original GitHub issueDescribe the bug The documented mocha testing examples have two problems.
To Reproduce Steps to reproduce the behavior: Clone https://github.com/itsMikeLowrey/testtingSpectron and run yarn run test:mocha
Expected behavior I expected the mocha testing to function correctly.
Environment (please complete the following information):
- (if possible) link to your repo: https://github.com/itsMikeLowrey/testtingSpectron
- terminal output from running
vue info
: Environment Info:
System: OS: Windows 10 10.0.19041 CPU: (4) x64 Intel® Core™ i5-4330M CPU @ 2.80GHz Binaries: Node: 12.18.3 - ~\AppData\Local\Temp\yarn–1597901458404-0.7356708428238694\node.CMD Yarn: 1.22.4 - ~\AppData\Local\Temp\yarn–1597901458404-0.7356708428238694\yarn.CMD npm: 6.14.6 - C:\Program Files\nodejs\npm.CMD Browsers: Chrome: 84.0.4147.135 Edge: Spartan (44.19041.1.0) npmPackages: @ant-design-vue/babel-helper-vue-transform-on: 1.0.1 @vue/babel-helper-vue-jsx-merge-props: 1.0.0 @vue/babel-plugin-transform-vue-jsx: 1.1.2 @vue/babel-preset-app: 4.5.4 @vue/babel-preset-jsx: 1.1.2 @vue/babel-sugar-functional-vue: 1.1.2 @vue/babel-sugar-inject-h: 1.1.2 @vue/babel-sugar-v-model: 1.1.2 @vue/babel-sugar-v-on: 1.1.2 @vue/cli: ^4.5.4 => 4.5.4 @vue/cli-overlay: 4.5.4 @vue/cli-plugin-babel: ~4.5.0 => 4.5.4 @vue/cli-plugin-eslint: ~4.5.0 => 4.5.4 @vue/cli-plugin-router: 4.5.4 @vue/cli-plugin-vuex: 4.5.4 @vue/cli-service: ~4.5.0 => 4.5.4 @vue/cli-shared-utils: 4.5.4 @vue/cli-ui: 4.5.4 @vue/cli-ui-addon-webpack: 4.5.4 @vue/cli-ui-addon-widgets: 4.5.4 @vue/compiler-core: 3.0.0-rc.6 @vue/compiler-dom: 3.0.0-rc.6 @vue/compiler-sfc: undefined (3.0.0-rc.6) @vue/compiler-ssr: 3.0.0-rc.6 @vue/component-compiler-utils: 3.2.0 @vue/preload-webpack-plugin: 1.1.2 @vue/reactivity: 3.0.0-rc.6 @vue/runtime-core: 3.0.0-rc.6 @vue/runtime-dom: 3.0.0-rc.6 @vue/shared: 3.0.0-rc.6 @vue/web-component-wrapper: 1.2.0 eslint-plugin-vue: ^6.2.2 => 6.2.2 typescript: 3.9.7 vue: ^2.6.11 => 2.6.11 (3.0.0-rc.6) vue-cli-plugin-apollo: 0.21.3 vue-cli-plugin-electron-builder: ~2.0.0-rc.4 => 2.0.0-rc.4 vue-codemod: 0.0.4 vue-eslint-parser: 7.1.0 vue-hot-reload-api: 2.3.4 vue-loader: 15.9.3 (16.0.0-beta.5) vue-style-loader: 4.1.2 vue-template-compiler: ^2.6.11 => 2.6.11 vue-template-es2015-compiler: 1.9.1 npmGlobalPackages: @vue/cli: Not Found
Additional context
The first issue that comes up is Error: Invalid Chai property: browserWindow.
This can be temporarily fixed by removing the problem code @ line 33 of test.spec.js.
The second issue is that the test always pass regardless if it should and it throws an assertion error. For example if I change the code at line 30 to
return this.app.client .getWindowCount() .should.eventually.have.at.least(45)
the test still passes but it returns this error:
UnhandledPromiseRejectionWarning: AssertionError: expected 1 to be at least 45
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Also, instead of using your own mocha config, try the official cli plugin, it may make things easier.
To fix, just use
"spectron": "11.0.0",
in yourpackage.json
.