-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
166 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/.nyc_output | ||
/coverage | ||
/node_modules | ||
/test/fixtures/compiled |
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
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,21 @@ | ||
const path = require('path'); | ||
const pkg = require('../package.json'); | ||
const makeProvider = require('..'); | ||
|
||
const withProvider = (t, run, identifier = 'ava-3.2') => run(t, makeProvider({ | ||
negotiateProtocol(identifiers, {version}) { | ||
t.true(identifiers.includes(identifier)); | ||
t.is(version, pkg.version); | ||
return { | ||
ava: {version: '3.2.0'}, | ||
identifier, | ||
normalizeGlobPatterns: patterns => patterns, | ||
async findFiles({patterns}) { | ||
return patterns.map(file => path.join(__dirname, file)); | ||
}, | ||
projectDir: __dirname | ||
}; | ||
} | ||
})); | ||
|
||
module.exports = withProvider; |
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,51 @@ | ||
const path = require('path'); | ||
const test = require('ava'); | ||
const del = require('del'); | ||
const execa = require('execa'); | ||
const withProvider = require('./_with-provider'); | ||
|
||
test.before('deleting compiled files', async t => { | ||
t.log(await del('test/fixtures/compiled')); | ||
}); | ||
|
||
const compile = async provider => { | ||
return { | ||
state: await provider.main({ | ||
config: { | ||
rewritePaths: { | ||
'typescript/': 'fixtures/', | ||
'compiled/': 'fixtures/compiled/' | ||
}, | ||
compile: true | ||
} | ||
}).compile() | ||
}; | ||
}; | ||
|
||
test('worker(): load rewritten paths files', withProvider, async (t, provider) => { | ||
const {state} = await compile(provider); | ||
const {stdout, stderr} = await execa.node( | ||
path.join(__dirname, 'fixtures/install-and-load'), | ||
['ava-3', JSON.stringify(state), path.join(__dirname, 'typescript', 'file.ts')], | ||
{cwd: path.join(__dirname, 'fixtures')} | ||
); | ||
if (stderr.length > 0) { | ||
t.log(stderr); | ||
} | ||
|
||
t.snapshot(stdout); | ||
}); | ||
|
||
test('worker(): runs compiled files', withProvider, async (t, provider) => { | ||
const {state} = await compile(provider); | ||
const {stdout, stderr} = await execa.node( | ||
path.join(__dirname, 'fixtures/install-and-load'), | ||
['ava-3', JSON.stringify(state), path.join(__dirname, 'compiled', 'typescript.ts')], | ||
{cwd: path.join(__dirname, 'fixtures')} | ||
); | ||
if (stderr.length > 0) { | ||
t.log(stderr); | ||
} | ||
|
||
t.snapshot(stdout); | ||
}); |
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 @@ | ||
console.log('logged in typescript.ts'); |
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
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,17 @@ | ||
# Snapshot report for `test/compilation.js` | ||
|
||
The actual snapshot is saved in `compilation.js.snap`. | ||
|
||
Generated by [AVA](https://avajs.dev). | ||
|
||
## worker(): load rewritten paths files | ||
|
||
> Snapshot 1 | ||
'logged in file.js' | ||
|
||
## worker(): runs compiled files | ||
|
||
> Snapshot 1 | ||
'logged in typescript.ts' |
Binary file not shown.
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
Binary file not shown.
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,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "fixtures/compiled" | ||
}, | ||
"include": [ | ||
"fixtures" | ||
] | ||
} |