diff --git a/.travis.yml b/.travis.yml index 5d9fca3251b..f0e048c107c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,7 +60,10 @@ script: fi - | if [[ "$JS" == "1" ]]; then - travis_retry npm run travis:test || exit 1 + npm run build || exit 1 # Build for tests. + npx gulp qunit || exit 1 # QUnit tests + npm run test || exit 1 # Bundle size test + travis_retry npm run travis:visualtest || exit 1 # Visual regression tests else gulp phpunit || exit 1 fi diff --git a/gulpfile.babel.js b/gulpfile.babel.js index d03e01257b5..39d1806dd8b 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -17,10 +17,10 @@ */ import gulp from 'gulp'; -import qunit from 'node-qunit-phantomjs'; import requireDir from 'require-dir'; import runSequence from 'run-sequence'; import livereload from 'gulp-livereload'; +import { execSync } from 'child_process'; var phpunit = require( 'gulp-phpunit' ); requireDir( './gulp-tasks' ); @@ -89,7 +89,7 @@ gulp.task( 'default', () => { } ); gulp.task( 'qunit', function() { - qunit( './tests/qunit/index.html' ); + execSync( 'node-qunit-phantomjs ./tests/qunit/index.html', { stdio: [ 0, 1, 2 ] } ); } ); gulp.task( 'phpunit', function() { diff --git a/package.json b/package.json index 6dd5479829e..f99179a5212 100644 --- a/package.json +++ b/package.json @@ -20,9 +20,6 @@ "test:visualtest": "npm run build && start-server-and-test storybook http-get://localhost:9001 backstopjs", "test:visualapprove": "backstop approve --config=backstop.js", "test:analyze": "webpack -p --mode=production --env.analyze=true --json --progress --profile > /tmp/stats.json && cp ./dist/assets/js/*.js /tmp && webpack-bundle-analyzer /tmp/stats.json", - "travis:test": "npm run build && npm run travis:qunit && npm run travis:phpunit && npm run travis:visualtest", - "travis:qunit": "gulp qunit", - "travis:phpunit": "gulp phpunit", "travis:visualtest": "start-server-and-test storybook http-get://localhost:9001 travis:backstopjs", "storybook": "start-storybook -s ./dist -p 9001 -c .storybook", "backstopjs": "backstop test --config=backstop.js --docker", diff --git a/tests/qunit/utils.js b/tests/qunit/assets/js/util/index.js similarity index 99% rename from tests/qunit/utils.js rename to tests/qunit/assets/js/util/index.js index 1d183b76b6b..d225b3c156c 100644 --- a/tests/qunit/utils.js +++ b/tests/qunit/assets/js/util/index.js @@ -21,7 +21,7 @@ googlesitekit.modules = { /** * Test showErrorNotification. */ -QUnit.test( 'showErrorNotification', function ( assert ) { +QUnit.test( 'showErrorNotification!', function ( assert ) { testFunctions.showErrorNotification(); var value = wp.hooks.applyFilters( 'googlesitekit.ErrorNotification', [] ); assert.equal( value.toString().replace( /(\r\n|\n|\r)/gm, '' ), 'function (r) {return React.createElement(e,a()({},r,t,{OriginalComponent:n}));}' ); @@ -261,7 +261,7 @@ var gtag = function( type, name, sendto, category, label, value ) { }; }; -var sendAnalyticsTrackingEventExpected = '{"type":"event","name":"name","sendto":{"event_category":"category","event_label":"label","event_value":"value"}}'; +var sendAnalyticsTrackingEventExpected = '{"type":"event","name":"name","sendto":{"event_category":"category","event_label":"label","event_value":"value","dimension1":"","dimension2":"true"}}'; QUnit.test( 'sendAnalyticsTrackingEvent', function ( assert ) { window.googlesitekit.admin.trackingOptin = true; const value = JSON.stringify( testFunctions.sendAnalyticsTrackingEvent( 'category', 'name', 'label', 'value' ) ); diff --git a/tests/qunit/index.html b/tests/qunit/index.html index 38ccf7b7262..066d487d8a4 100644 --- a/tests/qunit/index.html +++ b/tests/qunit/index.html @@ -9,11 +9,22 @@ + + + + @@ -25,10 +36,8 @@
- - - + \ No newline at end of file