question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mocha Testing Issue

See original GitHub issue

Describe 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):

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:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nklaymancommented, Aug 24, 2020

Also, instead of using your own mocha config, try the official cli plugin, it may make things easier.

1reaction
nklaymancommented, Aug 24, 2020

To fix, just use "spectron": "11.0.0", in your package.json.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mocha - the fun, simple, flexible JavaScript test framework
Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun.
Read more >
Issues · mochajs/mocha - GitHub
simple, flexible, fun javascript test framework for node.js & the browser - Issues · mochajs/mocha.
Read more >
Issue running mocha tests in nodejs - Stack Overflow
This seems like a problem with nyc itself. Try updating to the version suggested in this github issue: ...
Read more >
Automated testing with Mocha - The Modern JavaScript Tutorial
If the project is covered with tests, there's just no such problem. After any changes, we can run tests and see a lot...
Read more >
How To Test a Node.js Module with Mocha and Assert
Next, let's use automated testing in Node.js and see if we can solve this problem with the Mocha testing framework.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found