f8ad4d1e99
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
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
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
|
|
}
|
|
}
|
|
}
|