Skip to content

Commit

Permalink
chore: Add failing test for --all on pre-instrumented code
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyfarrell committed Nov 1, 2019
1 parent f890360 commit 65c6529
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
17 changes: 17 additions & 0 deletions tap-snapshots/test-instrument.js-TAP.test.js
@@ -0,0 +1,17 @@
/* IMPORTANT
* This snapshot file is auto-generated, but designed for humans.
* It should be checked into source control and tracked carefully.
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
* Make sure to inspect the output below. Do not ignore changes!
*/
'use strict'
exports[`test/instrument.js TAP can write files in place with --in-place switch > stdout 1`] = `
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 0 | 100 | 0 | 0 |
file1.js | 0 | 100 | 0 | 0 | 2,5
file2.js | 0 | 100 | 0 | 0 | 2,5
----------|---------|----------|---------|---------|-------------------
`
7 changes: 6 additions & 1 deletion test/instrument.js
Expand Up @@ -10,7 +10,7 @@ const cpFile = require('cp-file')
const isWindows = require('is-windows')()
const rimraf = promisify(require('rimraf'))

const { runNYC, fixturesCLI } = require('./helpers')
const { runNYC, testSuccess, fixturesCLI } = require('./helpers')

const subdir = path.resolve(fixturesCLI, 'subdir')
const outputDir = path.resolve(subdir, './output-dir')
Expand Down Expand Up @@ -264,6 +264,11 @@ t.test('can write files in place with --in-place switch', async t => {

const file2 = path.resolve(outputDir, 'file2.js')
t.notMatch(await fs.readFile(file2, 'utf8'), /function cov_/)

await testSuccess(t, {
args: ['--all', process.execPath, '-e', ''],
cwd: outputDir
})
})

t.test('aborts if trying to delete while writing files in place', async t => {
Expand Down

0 comments on commit 65c6529

Please sign in to comment.