Skip to content

Commit

Permalink
chore: Add a couple tsc tests (#1183)
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyfarrell committed Sep 29, 2019
1 parent c18fb0a commit 1f535d7
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tap-snapshots/test-tsc.js-TAP.test.js
@@ -0,0 +1,26 @@
/* 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/tsc.js TAP ignore source-map > stdout 1`] = `
------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
------------|---------|----------|---------|---------|-------------------
All files | 38.46 | 57.14 | 66.67 | 50 |
mapping.js | 38.46 | 57.14 | 66.67 | 50 | 3,4,5,6,8
------------|---------|----------|---------|---------|-------------------
`

exports[`test/tsc.js TAP reads source-map > stdout 1`] = `
------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
------------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
mapping.ts | 100 | 100 | 100 | 100 |
------------|---------|----------|---------|---------|-------------------
`
1 change: 1 addition & 0 deletions test/fixtures/tsc/.npmrc
@@ -0,0 +1 @@
package-lock=false
16 changes: 16 additions & 0 deletions test/fixtures/tsc/mapping.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/fixtures/tsc/mapping.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions test/fixtures/tsc/mapping.ts
@@ -0,0 +1,8 @@
function munge1 (obj: Object) {
return {
name: 'munge1',
...obj
};
}

munge1({})
15 changes: 15 additions & 0 deletions test/fixtures/tsc/package.json
@@ -0,0 +1,15 @@
{
"private": true,
"scripts": {
"postinstall": "tsc"
},
"devDependencies": {
"typescript": "^3.6.3"
},
"nyc": {
"reporter": [
"text",
"html"
]
}
}
8 changes: 8 additions & 0 deletions test/fixtures/tsc/tsconfig.json
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"sourceMap": true
},
"files": [
"mapping.ts"
]
}
28 changes: 28 additions & 0 deletions test/tsc.js
@@ -0,0 +1,28 @@
'use strict'

const path = require('path')
const t = require('tap')

const { testSuccess } = require('./helpers')
const fixturesTSC = path.resolve(__dirname, 'fixtures/tsc')

t.test('reads source-map', t => testSuccess(t, {
cwd: fixturesTSC,
args: [
'--produce-source-map=true',
'--cache=false',
process.execPath,
'mapping.js'
]
}))

t.test('ignore source-map', t => testSuccess(t, {
cwd: fixturesTSC,
args: [
'--produce-source-map=true',
'--no-source-map',
'--cache=false',
process.execPath,
'mapping.js'
]
}))

0 comments on commit 1f535d7

Please sign in to comment.