test(compiler-cli): compliance tests not always reporting test failure (#30597)
Currently the `@angular/compiler-cli` compliance tests sometimes do not throw an exception if the expected output does not match the generated JavaScript output. This can happen for the following cases: 1. Expected code includes character that is not part of known alphabet (e.g. `Δ` is still used in a new compliance test after rebasing a PR) 2. Expected code asserts that a string literal matches a string with escaped quotes. e.g. expects `const $var$ = "\"quoted\"";`) PR Close #30597
This commit is contained in:

committed by
Jason Aden

parent
3125376ec1
commit
70fd4300f4
@ -82,6 +82,34 @@ describe('mock_compiler', () => {
|
||||
result.source, 'name \n\n . \n length',
|
||||
'name length expression not found (whitespace)');
|
||||
});
|
||||
|
||||
it('should throw if the expected output contains unknown characters', () => {
|
||||
const files = {
|
||||
app: {
|
||||
'test.ts': `ɵsayHello();`,
|
||||
}
|
||||
};
|
||||
|
||||
const result = compile(files, angularFiles);
|
||||
|
||||
expect(() => {
|
||||
expectEmit(result.source, `ΔsayHello();`, 'Output does not match.');
|
||||
}).toThrowError(/Invalid test, no token found for "Δ"/);
|
||||
});
|
||||
|
||||
it('should be able to properly handle string literals with escaped quote', () => {
|
||||
const files = {
|
||||
app: {
|
||||
'test.ts': String.raw `const identifier = "\"quoted\"";`,
|
||||
}
|
||||
};
|
||||
|
||||
const result = compile(files, angularFiles);
|
||||
|
||||
expect(() => {
|
||||
expectEmit(result.source, String.raw `const $a$ = "\"quoted\"";`, 'Output does not match.');
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to skip untested regions (… and // ...)', () => {
|
||||
|
Reference in New Issue
Block a user