diff --git a/test/integration/karma-qunit.js b/test/integration/karma-qunit.js index b739f1b63..2cc635aa4 100644 --- a/test/integration/karma-qunit.js +++ b/test/integration/karma-qunit.js @@ -13,8 +13,6 @@ function normalize (str) { QUnit.module('karma-qunit', { before: () => { - // Need --legacy-peer-deps under npm 7 for "file:" override in package.json. - // Once CI and dev environments are on npm 8, consider using native "overrides". cp.execSync('npm install --prefer-offline --no-audit --omit=dev --legacy-peer-deps', { cwd: DIR, encoding: 'utf8' }); } }); diff --git a/test/integration/testem.js b/test/integration/testem.js new file mode 100644 index 000000000..88872e8cb --- /dev/null +++ b/test/integration/testem.js @@ -0,0 +1,36 @@ +const cp = require('child_process'); +const path = require('path'); +const DIR = path.join(__dirname, 'testem'); + +function normalize (str) { + return str + .trim() + .replace(/(Firefox) [\d.]+/g, '$1') + .replace(/(\d+ ms)/g, '0 ms'); +} + +QUnit.module('testem', { + before: () => { + // Let this be quick for re-runs + cp.execSync('npm install --prefer-offline --no-audit', { cwd: DIR, encoding: 'utf8' }); + } +}); + +QUnit.test('passing test', assert => { + const ret = cp.execSync('npm run -s test', { cwd: DIR, encoding: 'utf8' }); + assert.strictEqual( + normalize(ret), + ` +ok 1 Firefox - [0 ms] - add: two numbers + +1..1 +# tests 1 +# pass 1 +# skip 0 +# todo 0 +# fail 0 + +# ok + `.trim() + ); +}); diff --git a/test/integration/testem/README.md b/test/integration/testem/README.md new file mode 100644 index 000000000..cd52c6a17 --- /dev/null +++ b/test/integration/testem/README.md @@ -0,0 +1,20 @@ +# QUnit ♥️ Testem + +See also . + +```bash +npm test +``` + +``` +ok 1 Firefox - [0 ms] - add: two numbers + +1..1 +# tests 1 +# pass 1 +# skip 0 +# todo 0 +# fail 0 + +# ok +``` diff --git a/test/integration/testem/add.js b/test/integration/testem/add.js new file mode 100644 index 000000000..d52a88965 --- /dev/null +++ b/test/integration/testem/add.js @@ -0,0 +1,5 @@ +/* eslint-disable no-unused-vars */ + +function add (a, b) { + return a + b; +} diff --git a/test/integration/testem/add.test.js b/test/integration/testem/add.test.js new file mode 100644 index 000000000..098170c3b --- /dev/null +++ b/test/integration/testem/add.test.js @@ -0,0 +1,6 @@ +/* global add */ +QUnit.module('add', () => { + QUnit.test('two numbers', assert => { + assert.equal(add(1, 2), 3); + }); +}); diff --git a/test/integration/testem/package.json b/test/integration/testem/package.json new file mode 100644 index 000000000..09167ddd4 --- /dev/null +++ b/test/integration/testem/package.json @@ -0,0 +1,9 @@ +{ + "private": true, + "devDependencies": { + "testem": "3.13.0" + }, + "scripts": { + "test": "testem -l 'Headless Firefox' ci" + } +} diff --git a/test/integration/testem/qunit b/test/integration/testem/qunit new file mode 120000 index 000000000..24e236ddd --- /dev/null +++ b/test/integration/testem/qunit @@ -0,0 +1 @@ +../../../qunit \ No newline at end of file diff --git a/test/integration/testem/test.html b/test/integration/testem/test.html new file mode 100644 index 000000000..904120a92 --- /dev/null +++ b/test/integration/testem/test.html @@ -0,0 +1,18 @@ + + + +Testem + + + + + + + + +
+ + diff --git a/test/integration/testem/testem.json b/test/integration/testem/testem.json new file mode 100644 index 000000000..4f9ba0f88 --- /dev/null +++ b/test/integration/testem/testem.json @@ -0,0 +1,4 @@ +{ + "framework": "qunit", + "test_page": "test.html" +}