Skip to content

Commit

Permalink
Build: Enable ESLint on /test/integration/ fixtures
Browse files Browse the repository at this point in the history
Follows-up 0f6ec7c.
  • Loading branch information
Krinkle committed Apr 18, 2022
1 parent 1222426 commit 4f7738c
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 100 deletions.
18 changes: 17 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"lib/**",
"qunit/**",
"test/cli/fixtures/sourcemap/*.min.js",
"test/integration/*/**",
"test/integration/*/qunit/**",
"test/integration/*/coverage/**",
"test/integration/*/package-lock.json",
"temp/**"
],
"overrides": [
Expand Down Expand Up @@ -149,6 +151,20 @@
"compat/compat": "off"
}
},
{
"files": ["test/integration/**/*.js"],
"env": {
"browser": true,
"es2017": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"compat/compat": "off"
}
},
{
"files": ["test/**/*.html"],
"env": {
Expand Down
10 changes: 0 additions & 10 deletions test/integration/.eslintrc.json

This file was deleted.

76 changes: 37 additions & 39 deletions test/integration/grunt-contrib-qunit.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,47 @@
const cp = require( "child_process" );
const path = require( "path" );
const DIR = path.join( __dirname, "grunt-contrib-qunit" );
const cp = require('child_process');
const path = require('path');
const DIR = path.join(__dirname, 'grunt-contrib-qunit');

QUnit.module( "grunt-contrib-qunit", {
before: () => {
QUnit.module('grunt-contrib-qunit', {
before: () => {
// Let this be quick for re-runs
cp.execSync('npm install --prefer-offline --no-audit', { cwd: DIR, encoding: 'utf8' });
}
});

// Let this be quick for re-runs
cp.execSync( "npm install --prefer-offline --no-audit", { cwd: DIR, encoding: "utf8" } );
}
} );
QUnit.test('passing tests', assert => {
assert.expect(0);
cp.execSync('npm test', { cwd: DIR });
});

QUnit.test( "passing tests", assert => {
assert.expect( 0 );
cp.execSync( "npm test", { cwd: DIR } );
} );

QUnit.test.each( "failing tests", {
"assert": [ "fail-assert", `Testing fail-assert.html F
QUnit.test.each('failing tests', {
assert: ['fail-assert', `Testing fail-assert.html F
>> example
>> Message: some message
>> Actual: false
>> Expected: true
>> at ` ],
"no-tests": [ "fail-no-tests", `Testing fail-no-tests.html F
>> at `],
'no-tests': ['fail-no-tests', `Testing fail-no-tests.html F
>> global failure
>> Message: No tests were run.
>> Error: No tests were run.
>> at done (file:)` ]
}, ( assert, [ command, expected ] ) => {

try {
const ret = cp.execSync( "node_modules/.bin/grunt qunit:" + command, {
cwd: DIR,
env: {
CHROMIUM_FLAGS: process.env.CHROMIUM_FLAGS,
CI: process.env.CI,
PATH: process.env.PATH,
PUPPETEER_DOWNLOAD_PATH: process.env.PUPPETEER_DOWNLOAD_PATH
},
encoding: "utf8"
} );
assert.equal( ret, null );
} catch ( e ) {
const actual = e.stdout.replace( / \(file:.*$/gm, " (file:)" );
assert.pushResult( { result: actual.includes( expected ), actual, expected } );
assert.true( e.status > 0, "non-zero exit code" );
}
} );
>> at done (file:)`]
}, (assert, [command, expected]) => {
try {
const ret = cp.execSync('node_modules/.bin/grunt qunit:' + command, {
cwd: DIR,
env: {
CHROMIUM_FLAGS: process.env.CHROMIUM_FLAGS,
CI: process.env.CI,
PATH: process.env.PATH,
PUPPETEER_DOWNLOAD_PATH: process.env.PUPPETEER_DOWNLOAD_PATH
},
encoding: 'utf8'
});
assert.equal(ret, null);
} catch (e) {
const actual = e.stdout.replace(/ \(file:.*$/gm, ' (file:)');
assert.pushResult({ result: actual.includes(expected), actual, expected });
assert.true(e.status > 0, 'non-zero exit code');
}
});
32 changes: 16 additions & 16 deletions test/integration/grunt-contrib-qunit/Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/* eslint-env node */
module.exports = function( grunt ) {
grunt.loadNpmTasks( "grunt-contrib-qunit" );
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-qunit');

grunt.initConfig( {
qunit: {
options: {
puppeteer: {
args: ( process.env.CHROMIUM_FLAGS || ( process.env.CI ? "--no-sandbox" : "" ) )
.split( " " )
}
},
pass: [ "pass-*.html" ],
"fail-assert": "fail-assert.html",
"fail-no-tests": "fail-no-tests.html"
}
} );
grunt.initConfig({
qunit: {
options: {
puppeteer: {
args: (process.env.CHROMIUM_FLAGS || (process.env.CI ? '--no-sandbox' : ''))
.split(' ')
}
},
pass: ['pass-*.html'],
'fail-assert': 'fail-assert.html',
'fail-no-tests': 'fail-no-tests.html'
}
});

grunt.registerTask( "default", [ "qunit:pass" ] );
grunt.registerTask('default', ['qunit:pass']);
};
6 changes: 3 additions & 3 deletions test/integration/grunt-contrib-qunit/fail-assert.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<div id="qunit"></div>
<script src="qunit/qunit.js"></script>
<script>
QUnit.test( "example", function( assert ) {
assert.true( false, "some message" );
} );
QUnit.test('example', function (assert) {
assert.true(false, 'some message');
});
</script>
</body>
</html>
7 changes: 3 additions & 4 deletions test/integration/grunt-contrib-qunit/pass-basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
<div id="qunit"></div>
<script src="qunit/qunit.js"></script>
<script>
QUnit.test( "example", function( assert ) {
var x = true;
assert.equal( x, true, "x" );
} );
QUnit.test('example', function (assert) {
assert.true(true, 'x');
});
</script>
</body>
</html>
26 changes: 13 additions & 13 deletions test/integration/nyc.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const cp = require( "child_process" );
const path = require( "path" );
const DIR = path.join( __dirname, "nyc" );
const cp = require('child_process');
const path = require('path');
const DIR = path.join(__dirname, 'nyc');

QUnit.module( "nyc", {
before: () => {
cp.execSync( "npm install --prefer-offline --no-audit", { cwd: DIR, encoding: "utf8" } );
}
} );
QUnit.module('nyc', {
before: () => {
cp.execSync('npm install --prefer-offline --no-audit', { cwd: DIR, encoding: 'utf8' });
}
});

QUnit.test( "test", assert => {
const expected = `
QUnit.test('test', assert => {
const expected = `
TAP version 13
ok 1 add > two numbers
1..1
Expand All @@ -29,6 +29,6 @@ All files | 85.71 | 100 | 50 | 85.71 |
--------------|---------|----------|---------|---------|-------------------
`.trim();

const actual = cp.execSync( "npm test", { cwd: DIR, env: { PATH: process.env.PATH }, encoding: "utf8" } );
assert.pushResult( { result: actual.includes( expected ), actual, expected } );
} );
const actual = cp.execSync('npm test', { cwd: DIR, env: { PATH: process.env.PATH }, encoding: 'utf8' });
assert.pushResult({ result: actual.includes(expected), actual, expected });
});
8 changes: 4 additions & 4 deletions test/integration/nyc/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const add = require( "./src/add.js" );
const subtract = require( "./src/subtract.js" );
const add = require('./src/add.js');
const subtract = require('./src/subtract.js');

module.exports = {
add,
subtract
add,
subtract
};
4 changes: 2 additions & 2 deletions test/integration/nyc/src/add.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function add( a, b ) {
return a + b;
function add (a, b) {
return a + b;
}

module.exports = add;
4 changes: 2 additions & 2 deletions test/integration/nyc/src/subtract.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function substract( a, b ) {
return a - b;
function substract (a, b) {
return a - b;
}

module.exports = substract;
12 changes: 6 additions & 6 deletions test/integration/nyc/test/add.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const add = require( "../index.js" ).add;
const add = require('../index.js').add;

QUnit.module( "add", () => {
QUnit.test( "two numbers", assert => {
assert.equal( add( 1, 2 ), 3 );
} );
} );
QUnit.module('add', () => {
QUnit.test('two numbers', assert => {
assert.equal(add(1, 2), 3);
});
});

0 comments on commit 4f7738c

Please sign in to comment.