-
Notifications
You must be signed in to change notification settings - Fork 784
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests: Add integration with Istanbul NYC
- Loading branch information
Showing
9 changed files
with
110 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,34 @@ | ||
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.test( "test", assert => { | ||
const expected = ` | ||
TAP version 13 | ||
ok 1 add > two numbers | ||
1..1 | ||
# pass 1 | ||
# skip 0 | ||
# todo 0 | ||
# fail 0 | ||
--------------|---------|----------|---------|---------|------------------- | ||
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ||
--------------|---------|----------|---------|---------|------------------- | ||
All files | 85.71 | 100 | 50 | 85.71 | | ||
nyc | 100 | 100 | 100 | 100 | | ||
index.js | 100 | 100 | 100 | 100 | | ||
nyc/src | 75 | 100 | 50 | 75 | | ||
add.js | 100 | 100 | 100 | 100 | | ||
subtract.js | 50 | 100 | 0 | 50 | 2 | ||
--------------|---------|----------|---------|---------|------------------- | ||
`.trim(); | ||
|
||
const actual = cp.execSync( "npm test", { cwd: DIR, encoding: "utf8" } ); | ||
assert.pushResult( { result: actual.includes( expected ), actual, expected } ); | ||
} ); |
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,3 @@ | ||
/.nyc_output/ | ||
/coverage/ | ||
/node_modules/ |
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,25 @@ | ||
# QUnit ♥️ Istanbul | ||
|
||
```bash | ||
npm test | ||
``` | ||
|
||
``` | ||
TAP version 13 | ||
ok 1 add > two numbers | ||
1..1 | ||
# pass 1 | ||
# skip 0 | ||
# todo 0 | ||
# fail 0 | ||
--------------|---------|----------|---------|---------|------------------- | ||
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ||
--------------|---------|----------|---------|---------|------------------- | ||
All files | 85.71 | 100 | 50 | 85.71 | | ||
nyc | 100 | 100 | 100 | 100 | | ||
index.js | 100 | 100 | 100 | 100 | | ||
nyc/src | 75 | 100 | 50 | 75 | | ||
add.js | 100 | 100 | 100 | 100 | | ||
subtract.js | 50 | 100 | 0 | 50 | 2 | ||
--------------|---------|----------|---------|---------|------------------- | ||
``` |
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,7 @@ | ||
const add = require( "./src/add.js" ); | ||
const subtract = require( "./src/subtract.js" ); | ||
|
||
module.exports = { | ||
add, | ||
subtract | ||
}; |
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,21 @@ | ||
{ | ||
"private": true, | ||
"devDependencies": { | ||
"nyc": "15.1.0", | ||
"qunit": "file:../../.." | ||
}, | ||
"scripts": { | ||
"test": "nyc qunit" | ||
}, | ||
"nyc": { | ||
"exclude": [ | ||
"test/" | ||
], | ||
"report-dir": "coverage/", | ||
"reporter": [ | ||
"text", | ||
"html", | ||
"lcov" | ||
] | ||
} | ||
} |
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 @@ | ||
function add( a, b ) { | ||
return a + b; | ||
} | ||
|
||
module.exports = add; |
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 @@ | ||
function substract( a, b ) { | ||
return a - b; | ||
} | ||
|
||
module.exports = substract; |
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,7 @@ | ||
const add = require( "../index.js" ).add; | ||
|
||
QUnit.module( "add", () => { | ||
QUnit.test( "two numbers", assert => { | ||
assert.equal( add( 1, 2 ), 3 ); | ||
} ); | ||
} ); |