-
Notifications
You must be signed in to change notification settings - Fork 780
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test: Add Testem integration example
- Loading branch information
Showing
9 changed files
with
99 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# QUnit ♥️ Testem | ||
|
||
See also <https://github.com/testem/testem/>. | ||
|
||
```bash | ||
npm test | ||
``` | ||
|
||
``` | ||
ok 1 Firefox - [0 ms] - add: two numbers | ||
1..1 | ||
# tests 1 | ||
# pass 1 | ||
# skip 0 | ||
# todo 0 | ||
# fail 0 | ||
# ok | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* eslint-disable no-unused-vars */ | ||
|
||
function add (a, b) { | ||
return a + b; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* global add */ | ||
QUnit.module('add', () => { | ||
QUnit.test('two numbers', assert => { | ||
assert.equal(add(1, 2), 3); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"private": true, | ||
"devDependencies": { | ||
"testem": "3.13.0" | ||
}, | ||
"scripts": { | ||
"test": "testem -l 'Headless Firefox' ci" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../qunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Testem</title> | ||
<link rel="stylesheet" href="/qunit/qunit.css"> | ||
<script src="/testem.js"></script> | ||
<script src="/qunit/qunit.js"></script> | ||
<script src="add.js"></script> | ||
<script src="add.test.js"></script> | ||
<script> | ||
/* global Testem */ | ||
Testem.hookIntoTestFramework(); | ||
</script> | ||
</head> | ||
<body> | ||
<div id="qunit"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"framework": "qunit", | ||
"test_page": "test.html" | ||
} |