-
-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tests): rework vue integration tests
- do not create a IncrementalChecker instance on the test thread - use worker-rpc so the tests can actually access the checker instance run by the service - fix include path in "tsconfig-imports.json" so the "should resolve *.vue in the same way as TypeScript" test actually compiles files - add two counter checks to make sure the compiler actually throws errors it finds at all
- Loading branch information
1 parent
271278d
commit 5ad2568
Showing
8 changed files
with
449 additions
and
306 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
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,57 @@ | ||
const mock = require('mock-require'); | ||
|
||
const origImport = require('../../../lib/ApiIncrementalChecker'); | ||
const { rpcMethods, getRpcProvider } = require('../helpers'); | ||
|
||
mock('../../../lib/ApiIncrementalChecker', { | ||
ApiIncrementalChecker: class extends origImport.ApiIncrementalChecker { | ||
constructor(...args) { | ||
super(...args); | ||
|
||
const rpc = getRpcProvider(); | ||
|
||
const awaitInit = async () => { | ||
if (!this.tsIncrementalCompiler.lastProcessing) { | ||
await this.tsIncrementalCompiler.processChanges(); | ||
} else { | ||
await this.tsIncrementalCompiler.lastProcessing; | ||
} | ||
}; | ||
|
||
rpc.registerRpcHandler(rpcMethods.checker_nextIteration, () => { | ||
return this.nextIteration(); | ||
}); | ||
|
||
rpc.registerRpcHandler(rpcMethods.checker_getKnownFileNames, async () => { | ||
await awaitInit(); | ||
return Array.from(this.tsIncrementalCompiler.getAllKnownFiles()); | ||
}); | ||
|
||
rpc.registerRpcHandler( | ||
rpcMethods.checker_getSourceFile, | ||
async fileName => { | ||
await awaitInit(); | ||
const result = this.tsIncrementalCompiler | ||
.getProgram() | ||
.getSourceFile(fileName); | ||
return !result ? undefined : { text: result.text }; | ||
} | ||
); | ||
|
||
rpc.registerRpcHandler( | ||
rpcMethods.checker_getSyntacticDiagnostics, | ||
async () => { | ||
await awaitInit(); | ||
const result = this.tsIncrementalCompiler | ||
.getProgram() | ||
.getSyntacticDiagnostics(); | ||
return result.map(({ start, length, file }) => ({ | ||
start, | ||
length, | ||
file: { text: file.text } | ||
})); | ||
} | ||
); | ||
} | ||
} | ||
}); |
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,37 @@ | ||
const mock = require('mock-require'); | ||
|
||
const origImport = require('../../../lib/IncrementalChecker'); | ||
|
||
const { rpcMethods, getRpcProvider } = require('../helpers'); | ||
|
||
mock('../../../lib/IncrementalChecker', { | ||
IncrementalChecker: class extends origImport.IncrementalChecker { | ||
constructor(...args) { | ||
super(...args); | ||
|
||
const rpc = getRpcProvider(); | ||
|
||
rpc.registerRpcHandler(rpcMethods.checker_nextIteration, () => { | ||
return this.nextIteration(); | ||
}); | ||
|
||
rpc.registerRpcHandler(rpcMethods.checker_getKnownFileNames, () => { | ||
return this.programConfig.fileNames; | ||
}); | ||
|
||
rpc.registerRpcHandler(rpcMethods.checker_getSourceFile, fileName => { | ||
const result = this.program.getSourceFile(fileName); | ||
return !result ? undefined : { text: result.text }; | ||
}); | ||
|
||
rpc.registerRpcHandler(rpcMethods.checker_getSyntacticDiagnostics, () => { | ||
const result = this.program.getSyntacticDiagnostics(); | ||
return result.map(({ start, length, file }) => ({ | ||
start, | ||
length, | ||
file: { text: file.text } | ||
})); | ||
}); | ||
} | ||
} | ||
}); |
Oops, something went wrong.