Mocha unit tests failing
See original GitHub issueThis might not be an issue specific to this project, but I haven’t been able to find a solution. When running npm run test
out of the box, it looks like es6 imports aren’t working:
$ yarn test
yarn test v0.18.1
$ mocha --compilers js:babel-register
/Users/akoehler/Development/Repos/react-static-boilerplate/test/base.test.js:1
(function (exports, require, module, __filename, __dirname) { import { expect } from 'chai';
^^^^^^
SyntaxError: Unexpected token import
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
...
...
I installed with node v6.9.4.
edit: I was able to get this working by copying the babel configuration in package.json
to a .babelrc
file within the test
directory and removing the "modules": false
configuration from the “es2015” preset.
{
"presets": [
"react",
"es2015",
"stage-1"
],
"plugins": [
"transform-runtime"
]
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
How to get Mocha to fail a test - Stack Overflow
The test execution path is correct. When I have validating data, it goes to "SHOULD NOT GET HERE". The test is really to...
Read more >Mocha - the fun, simple, flexible JavaScript test framework
Mocha is a feature-rich JavaScript test framework running on Node.js and in the ... The above test will fail with Error: Resolution method...
Read more >Mocha might crash on unit testing failure randomly · Issue #1803
This is hard to provide reproduce code, but we get mocha randomly crashed if there is unit testing failure. We have +700 test...
Read more >Getting Started with Node.js and Mocha - Semaphore Tutorial
Mocha is a simple, extensible and fast testing library for Node.js. This article will walk you through its installation, configuration and usage.
Read more >Testing Error Handling in node.js | by Lars Trieloff
I've found myself adapting the following patterns to writing unit tests for ... (and will cause npm test to fail when the thresholds...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Implemented the fix worked for me. If anyone else out there is using Relay and needing to add babelRelayPlugin as a preset, this is what my webpack.config.js looks like:
That should work great. Thanks @koistya!