Skip to content

Commit

Permalink
Tests: Remove Mocha test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Jul 6, 2017
1 parent 7fc46cd commit 7375464
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 71 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Gutenberg contains both PHP and JavaScript code, and encourages testing and code

### JavaScript Testing

Tests for JavaScript use [Mocha](https://mochajs.org/) as the test runner and [Chai BDD](http://chaijs.com/api/bdd/) as an assertion library (with a [small variation](https://github.com/prodatakey/dirty-chai) on assertion properties). If needed, you can also use [Sinon](http://sinonjs.org/) for mocking and [Enzyme](https://github.com/airbnb/enzyme) for React component testing.
Tests for JavaScript use [Jest](http://facebook.github.io/jest//) as the test runner. If needed, you can also use [Sinon](http://sinonjs.org/) for mocking and [Enzyme](https://github.com/airbnb/enzyme) for React component testing.

Assuming you've followed the instructions above to install Node and project dependencies, tests can be run from the command-line with NPM:

Expand Down
27 changes: 0 additions & 27 deletions bootstrap-test.js

This file was deleted.

5 changes: 0 additions & 5 deletions components/form-token-field/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,6 @@ maybeDescribe( 'FormTokenField', function() {
} );

it( 'should manage the selected suggestion based on both keyboard and mouse events', test( function() {
// We need a high timeout for Mocha here to accomodate Travis CI
if ( this.timeout ) {
this.timeout( 10000 );
}

setText( 'th' );
expect( getSuggestionsText() ).to.deep.equal( fixtures.matchingSuggestions.th );
expect( getSelectedSuggestion() ).to.equal( null );
Expand Down
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,8 @@
"expose-loader": "^0.7.3",
"extract-text-webpack-plugin": "^2.1.0",
"gettext-parser": "^1.2.2",
"glob": "^7.1.1",
"jest": "~20.0.4",
"jest-junit-reporter": "~1.1.0",
"jsdom": "^10.1.0",
"mocha": "^3.2.0",
"node-sass": "^4.5.0",
"pegjs": "^0.10.0",
"pegjs-loader": "^0.5.1",
Expand All @@ -85,11 +82,9 @@
"sinon-test": "^1.0.2",
"style-loader": "^0.14.1",
"tinymce": "^4.5.6",
"webpack": "^2.2.1",
"webpack-node-externals": "^1.5.4"
"webpack": "^2.2.1"
},
"scripts": {
"test-unit": "cross-env NODE_ENV=test webpack && mocha build --require bootstrap-test.js",
"build": "cross-env BABEL_ENV=default NODE_ENV=production webpack",
"gettext-strings": "cross-env BABEL_ENV=gettext webpack",
"lint": "eslint . .storybook",
Expand All @@ -99,7 +94,7 @@
"package-plugin": "./bin/build-plugin-zip.sh",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook",
"test-unit:jest": "jest",
"test-unit": "jest",
"test-unit:coverage": "jest --coverage",
"test-unit:watch": "jest --watch"
},
Expand Down
31 changes: 0 additions & 31 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* External dependencies
*/

const glob = require( 'glob' );
const webpack = require( 'webpack' );
const ExtractTextPlugin = require( 'extract-text-webpack-plugin' );

Expand Down Expand Up @@ -149,35 +147,6 @@ switch ( process.env.NODE_ENV ) {
config.plugins.push( new webpack.optimize.UglifyJsPlugin() );
break;

case 'test':
config.target = 'node';
config.node = {
__dirname: true,
};
config.module.rules = [
...entryPointNames.map( ( entry ) => ( {
test: require.resolve( './' + entry + '/index.js' ),
use: 'expose-loader?wp.' + entry,
} ) ),
...config.module.rules,
];
const testFiles = glob.sync(
'./{' + Object.keys( config.entry ).sort() + '}/**/test/*.js'
);
config.entry = [
...entryPointNames.map(
entryPointName => './' + entryPointName + '/index.js'
),
...testFiles.filter( f => /full-content\.js$/.test( f ) ),
...testFiles.filter( f => ! /full-content\.js$/.test( f ) ),
];
config.externals = [ require( 'webpack-node-externals' )() ];
config.output = {
filename: 'build/test.js',
path: __dirname,
};
break;

default:
config.devtool = 'source-map';
}
Expand Down

0 comments on commit 7375464

Please sign in to comment.