-
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.
Have the watcher ignore changes to the original TypeScript source files. This way, the watcher will only react to changes to the TypeScript build output. Allow the watcher to resolve the rewritten path of a test file, so it can track it as a dependency of the original TypeScript source file. This way, when the build output changes, the watcher knows to re-run the original test file. Update file patterns to ignore *.d.ts files, as well as any files in the build output. Updated the ignored-by-watcher patterns to ignore source map files from the build output. Fixes #10, #7, #9.
- Loading branch information
1 parent
a5ea5ce
commit 586d820
Showing
4 changed files
with
110 additions
and
6 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,43 @@ | ||
const path = require('path'); | ||
const test = require('ava'); | ||
const pkg = require('../package.json'); | ||
const makeProvider = require('..'); | ||
|
||
const withProvider = (t, run) => run(t, makeProvider({ | ||
negotiateProtocol(identifiers, {version}) { | ||
t.true(identifiers.includes('ava-3.2')); | ||
t.is(version, pkg.version); | ||
return { | ||
ava: {version: '3.2.0'}, | ||
identifier: 'ava-3.2', | ||
normalizeGlobPatterns: patterns => patterns, | ||
async findFiles({patterns}) { | ||
return patterns.map(file => path.join(__dirname, file)); | ||
}, | ||
projectDir: __dirname | ||
}; | ||
} | ||
})); | ||
|
||
test('negotiates ava-3.2 protocol', withProvider, t => t.plan(2)); | ||
|
||
test('main() ignoreChange()', withProvider, (t, provider) => { | ||
const main = provider.main({config: {rewritePaths: {'src/': 'build/'}}}); | ||
t.true(main.ignoreChange(path.join(__dirname, 'src/foo.ts'))); | ||
t.false(main.ignoreChange(path.join(__dirname, 'build/foo.js'))); | ||
}); | ||
|
||
test('main() resolveTestfile()', withProvider, (t, provider) => { | ||
const main = provider.main({config: {rewritePaths: {'src/': 'build/'}}}); | ||
t.is(main.resolveTestFile(path.join(__dirname, 'src/foo.ts')), path.join(__dirname, 'build/foo.js')); | ||
t.is(main.resolveTestFile(path.join(__dirname, 'build/foo.js')), path.join(__dirname, 'build/foo.js')); | ||
t.is(main.resolveTestFile(path.join(__dirname, 'foo/bar.ts')), path.join(__dirname, 'foo/bar.ts')); | ||
}); | ||
|
||
test('main() updateGlobs()', withProvider, (t, provider) => { | ||
const main = provider.main({config: {rewritePaths: {'src/': 'build/'}}}); | ||
t.snapshot(main.updateGlobs({ | ||
filePatterns: ['src/test.ts'], | ||
ignoredByWatcherPatterns: ['assets/**'] | ||
})); | ||
}); |
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 @@ | ||
# Snapshot report for `test/protocol-ava-3.2.js` | ||
|
||
The actual snapshot is saved in `protocol-ava-3.2.js.snap`. | ||
|
||
Generated by [AVA](https://avajs.dev). | ||
|
||
## main() updateGlobs() | ||
|
||
> Snapshot 1 | ||
{ | ||
filePatterns: [ | ||
'src/test.ts', | ||
'!**/*.d.ts', | ||
'!build/**', | ||
], | ||
ignoredByWatcherPatterns: [ | ||
'assets/**', | ||
'build/**/*.js.map', | ||
], | ||
} |
Binary file not shown.