test(language-service): Improve integration test (#28168)
The current integration test for language service involves piping the results of one process to another using Unix pipes. This makes the test hard to debug, and hard to configure. This commit refactors the integration test to use regular Jasmine scaffolding. More importantly, it tests the way the language service will actually be installed by end users. Users would not have to add `@angular/language-service` to the plugins section in tsconfig.json Instead, all they need to do is install the *extension* from the VS Code Marketplace and Angular Language Service will be loaded as a global plugin. PR Close #28168
This commit is contained in:

committed by
Alex Rickabaugh

parent
5a582a8afd
commit
f8ad4d1e99
32
integration/language_service_plugin/matcher.ts
Normal file
32
integration/language_service_plugin/matcher.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import { writeFileSync } from 'fs';
|
||||
|
||||
const goldens: string[] = process.argv.slice(2);
|
||||
|
||||
export const goldenMatcher: jasmine.CustomMatcherFactories = {
|
||||
toMatchGolden(util: jasmine.MatchersUtil): jasmine.CustomMatcher {
|
||||
return {
|
||||
compare(actual: {command: string}, golden: string): jasmine.CustomMatcherResult {
|
||||
const expected = require(`./goldens/${golden}`);
|
||||
const pass = util.equals(actual, expected);
|
||||
if (!pass && goldens.indexOf(golden) >= 0) {
|
||||
console.error(`Writing golden file ${golden}`);
|
||||
writeFileSync(`./goldens/${golden}`, JSON.stringify(actual, null, 2));
|
||||
return { pass : true };
|
||||
}
|
||||
return {
|
||||
pass,
|
||||
message: `Expected response for '${actual.command}' to match golden file ${golden}.\n` +
|
||||
`To generate new golden file, run "yarn golden ${golden}".`,
|
||||
};
|
||||
}
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
declare global {
|
||||
namespace jasmine {
|
||||
interface Matchers<T> {
|
||||
toMatchGolden(golden: string): void
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user