Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proposal: Use Mocha as a test runner with jsdom (#847)
* Bump babel dependencies - babel-cli - babel-core - babel-loader - babel-plugin-transform-react-constant-elements - babel-plugin-transform-react-inline-elements - babel-plugin-transform-react-remove-prop-types - babel-preset-es2015 - babel-preset-react - babel-preset-stage-0 * Add babel-register as dev dependency * Replace karma test runner with mocha - Add setup.js which: - requires babel-register - Initialises jsdom by loading document into global scope - Add compilers/css to ignore css extensions - Replace test, test:watch commands with mocha * Modify tests to use relative paths for mocha - import sinon because we no longer inject it in karma * Remove karma dependencies 🎉 - We no longer use webpack to pack our tests - Removed: - karma - karma-jsdom-launcher - karma-mocha - karma-mocha-reporter - karma-sinon - karma-sourcemap-loader - null-loader - Added: - jsdom * Remove unneeded tests.webpack.js * Remove unneeded karma.conf.js * Modify eslintignore to remove tests.webpack and karma.conf - Removed as they no longer exist * Modify README to no longer mention karma for unit tests
- Loading branch information
1 parent
d5f7139
commit 467cb09
Showing
11 changed files
with
51 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
/compiled/** | ||
/public/** | ||
/webpack/** | ||
karma.conf.js | ||
tests.webpack.js | ||
/api/promiseMiddleware.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
function noop() { return null; } | ||
|
||
require.extensions['.css'] = noop; | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require('babel-register') ({ | ||
presets: ['es2015', 'react', 'stage-0'] | ||
}); | ||
var jsdom = require('jsdom').jsdom; | ||
|
||
var exposedProperties = ['window', 'navigator', 'document']; | ||
|
||
global.document = jsdom(''); | ||
global.window = document.defaultView; | ||
Object.keys(document.defaultView).forEach((property) => { | ||
if (typeof global[property] === 'undefined') { | ||
exposedProperties.push(property); | ||
global[property] = document.defaultView[property]; | ||
} | ||
}); | ||
|
||
global.navigator = { | ||
userAgent: 'node.js' | ||
}; | ||
|
||
documentRef = document; | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters