Skip to content

Commit

Permalink
fix up unit tests in chipper, phetsims/perennial#384
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Nov 13, 2024
1 parent c6e564d commit 075063e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"url": "https://github.com/phetsims/chipper.git"
},
"scripts": {
"test": "bash ../perennial-alias/bin/sage run ../perennial-alias/node_modules/qunit/bin/qunit.js test/chipper-tests.js"
"test": "bash ../perennial-alias/bin/sage run ../perennial-alias/node_modules/qunit/bin/qunit.js test/chipper-tests.js",
"test-long": "bash ../perennial-alias/bin/sage run ../perennial-alias/node_modules/qunit/bin/qunit.js test/*"
},
"phet": {
"chipperSupportsOutputJSGruntTasks": true,
Expand Down
22 changes: 11 additions & 11 deletions test/chainsBuildTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

// const assert = require( 'assert' );
// const chai = require( 'chai' );
const execute = require( '../js/grunt/execute.js' );
const execute = require( '../../perennial-alias/js/common/execute.js' );
const gruntCommand = require( '../../perennial-alias/js/common/gruntCommand.js' );
const grunt = require( 'grunt' );
const qunit = require( '../../perennial-alias/js/npm-dependencies/qunit.js' );

const gruntCommand = /^win/.test( process.platform ) ? 'grunt.cmd' : 'grunt';

qunit.module( 'Chains building' );

Expand Down Expand Up @@ -58,61 +58,61 @@ function assertChainsExistence( assert, brand, options ) {

qunit.test( 'Build (no args)', async assert => {
assert.timeout( 120000 );
await execute( gruntCommand, [ '--brands=phet,phet-io' ], { cwd: '../chains' } );
await execute( gruntCommand, [ '--brands=phet,phet-io' ], '../chains' );
assertChainsExistence( assert, 'phet', {} );
assertChainsExistence( assert, 'phet-io', {} );
} );

qunit.test( 'Build (with added HTMLs)', async assert => {
assert.timeout( 120000 );
await execute( gruntCommand, [ '--brands=phet,phet-io', '--debugHTML' ], { cwd: '../chains' } );
await execute( gruntCommand, [ '--brands=phet,phet-io', '--debugHTML' ], '../chains' );
assertChainsExistence( assert, 'phet', { allHTML: true, debugHTML: true } );
assertChainsExistence( assert, 'phet-io', { allHTML: true, debugHTML: true } );
} );

qunit.test( 'Build (no uglification)', async assert => {
assert.timeout( 120000 );
await execute( gruntCommand, [ '--brands=phet,phet-io', '--uglify=false' ], { cwd: '../chains' } );
await execute( gruntCommand, [ '--brands=phet,phet-io', '--uglify=false' ], '../chains' );
assertChainsExistence( assert, 'phet', {} );
assertChainsExistence( assert, 'phet-io', {} );
} );

qunit.test( 'Build (no mangling)', async assert => {
assert.timeout( 120000 );
await execute( gruntCommand, [ '--brands=phet,phet-io', '--mangle=false' ], { cwd: '../chains' } );
await execute( gruntCommand, [ '--brands=phet,phet-io', '--mangle=false' ], '../chains' );
assertChainsExistence( assert, 'phet', {} );
assertChainsExistence( assert, 'phet-io', {} );
} );

qunit.test( 'Build (instrument)', async assert => {
assert.timeout( 120000 );
await execute( gruntCommand, [ '--brands=phet,phet-io', '--instrument', '--uglify=false' ], { cwd: '../chains' } );
await execute( gruntCommand, [ '--brands=phet,phet-io', '--instrument', '--uglify=false' ], '../chains' );
assertChainsExistence( assert, 'phet', {} );
assertChainsExistence( assert, 'phet-io', {} );
} );

qunit.test( 'Build (all locales)', async assert => {
assert.timeout( 120000 );
await execute( gruntCommand, [ '--brands=phet,phet-io', '--locales=*' ], { cwd: '../chains' } );
await execute( gruntCommand, [ '--brands=phet,phet-io', '--locales=*' ], '../chains' );
assertChainsExistence( assert, 'phet', { locales: [ 'en', 'ar', 'es', 'zh_CN' ] } );
assertChainsExistence( assert, 'phet-io', {} );
} );

qunit.test( 'Build (es,zh_CN locales)', async assert => {
assert.timeout( 120000 );
await execute( gruntCommand, [ '--brands=phet,phet-io', '--locales=es,zh_CN' ], { cwd: '../chains' } );
await execute( gruntCommand, [ '--brands=phet,phet-io', '--locales=es,zh_CN' ], '../chains' );
assertChainsExistence( assert, 'phet', { locales: [ 'es', 'zh_CN' ] } );
assertChainsExistence( assert, 'phet-io', {} );
} );

qunit.test( 'Build (phet brand only)', async assert => {
assert.timeout( 120000 );
await execute( gruntCommand, [ '--brands=phet' ], { cwd: '../chains' } );
await execute( gruntCommand, [ '--brands=phet' ], '../chains' );
assertChainsExistence( assert, 'phet', {} );
} );

qunit.test( 'Build (phet-io brand only)', async assert => {
assert.timeout( 120000 );
await execute( gruntCommand, [ '--brands=phet-io' ], { cwd: '../chains' } );
await execute( gruntCommand, [ '--brands=phet-io' ], '../chains' );
assertChainsExistence( assert, 'phet-io', {} );
} );
20 changes: 10 additions & 10 deletions test/generationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,50 @@


// const chai = require( 'chai' );
const execute = require( '../js/grunt/execute.js' );
const gruntCommand = /^win/.test( process.platform ) ? 'grunt.cmd' : 'grunt';
const execute = require( '../../perennial-alias/js/common/execute.js' );
const gruntCommand = require( '../../perennial-alias/js/common/gruntCommand.js' );
const qunit = require( '../../perennial-alias/js/npm-dependencies/qunit.js' );

qunit.module( 'Generation', {
afterEach: async () => {
// Hard reset to undo what we just did
await execute( 'git', [ 'reset', '--hard' ], { cwd: '../chains' } );
await execute( 'git', [ 'clean', '-f' ], { cwd: '../chains' } );
await execute( 'git', [ 'reset', '--hard' ], '../chains' );
await execute( 'git', [ 'clean', '-f' ], '../chains' );
}
} );

qunit.test( 'Development HTML', async assert => {
assert.timeout( 120000 );
await execute( gruntCommand, [ 'generate-development-html' ], { cwd: '../chains' } );
await execute( gruntCommand, [ 'generate-development-html' ], '../chains' );
assert.expect( 0 );
} );

qunit.test( 'Test HTML', async assert => {
assert.timeout( 120000 );
await execute( gruntCommand, [ 'generate-test-html' ], { cwd: '../chains' } );
await execute( gruntCommand, [ 'generate-test-html' ], '../chains' );
assert.expect( 0 );
} );

qunit.test( 'A11Y View HTML', async assert => {
assert.timeout( 120000 );
await execute( gruntCommand, [ 'generate-a11y-view-html' ], { cwd: '../chains' } );
await execute( gruntCommand, [ 'generate-a11y-view-html' ], '../chains' );
assert.expect( 0 );
} );

qunit.test( 'Published README', async assert => {
assert.timeout( 120000 );
await execute( gruntCommand, [ 'published-readme' ], { cwd: '../chains' } );
await execute( gruntCommand, [ 'published-readme' ], '../chains' );
assert.expect( 0 );
} );

qunit.test( 'Unpublished README', async assert => {
assert.timeout( 120000 );
await execute( gruntCommand, [ 'unpublished-readme' ], { cwd: '../chains' } );
await execute( gruntCommand, [ 'unpublished-readme' ], '../chains' );
assert.expect( 0 );
} );

qunit.test( 'Copyright', async assert => {
assert.timeout( 120000 );
await execute( gruntCommand, [ 'update-copyright-dates' ], { cwd: '../chains' } );
await execute( gruntCommand, [ 'update-copyright-dates' ], '../chains' );
assert.expect( 0 );
} );

0 comments on commit 075063e

Please sign in to comment.