Skip to content

Commit

Permalink
fix(testing): allow support of svg templates
Browse files Browse the repository at this point in the history
Angular 8 supports SVG files in addition of HTML for component templates but they were not correctly parsed by Jest. All tests including SVG templates failed as below:
```sh
    SyntaxError: /path/to/file.svg: Unexpected token (1:0)

    > 1 | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 37.62 37.12">
```
  • Loading branch information
Yannick Galatol authored and vsavkin committed Sep 11, 2019
1 parent 4ef3a77 commit 14da0ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions packages/jest/src/builders/jest/jest.impl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('Jest Builder', () => {
diagnostics: {
warnOnly: true
},
stringifyContentPathRegex: '\\.html$',
stringifyContentPathRegex: '\\.(html|svg)$',
astTransformers: [
'jest-preset-angular/InlineHtmlStripStylesTransformer'
]
Expand Down Expand Up @@ -95,7 +95,7 @@ describe('Jest Builder', () => {
diagnostics: {
warnOnly: true
},
stringifyContentPathRegex: '\\.html$',
stringifyContentPathRegex: '\\.(html|svg)$',
astTransformers: [
'jest-preset-angular/InlineHtmlStripStylesTransformer'
]
Expand Down Expand Up @@ -141,7 +141,7 @@ describe('Jest Builder', () => {
diagnostics: {
warnOnly: true
},
stringifyContentPathRegex: '\\.html$',
stringifyContentPathRegex: '\\.(html|svg)$',
astTransformers: [
'jest-preset-angular/InlineHtmlStripStylesTransformer'
]
Expand Down Expand Up @@ -198,7 +198,7 @@ describe('Jest Builder', () => {
diagnostics: {
warnOnly: true
},
stringifyContentPathRegex: '\\.html$',
stringifyContentPathRegex: '\\.(html|svg)$',
astTransformers: [
'jest-preset-angular/InlineHtmlStripStylesTransformer'
]
Expand Down Expand Up @@ -251,7 +251,7 @@ describe('Jest Builder', () => {
diagnostics: {
warnOnly: true
},
stringifyContentPathRegex: '\\.html$',
stringifyContentPathRegex: '\\.(html|svg)$',
astTransformers: [
'jest-preset-angular/InlineHtmlStripStylesTransformer'
]
Expand Down
2 changes: 1 addition & 1 deletion packages/jest/src/builders/jest/jest.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function run(
try {
require.resolve('jest-preset-angular');
Object.assign(tsJestConfig, {
stringifyContentPathRegex: '\\.html$',
stringifyContentPathRegex: '\\.(html|svg)$',
astTransformers: ['jest-preset-angular/InlineHtmlStripStylesTransformer']
});
} catch (e) {}
Expand Down

0 comments on commit 14da0ff

Please sign in to comment.