diff --git a/example/package.json b/example/package.json index 605c8fe006..d7c2fcbf22 100644 --- a/example/package.json +++ b/example/package.json @@ -7,6 +7,7 @@ "start": "ng serve", "build": "ng build", "test": "jest", + "test": "jest", "test:watch": "jest --watch", "test:ci": "jest --runInBand", "test:coverage": "jest --coverage", @@ -37,6 +38,7 @@ "codelyzer": "^4.4.3", "jest": "^24.0.0", "jest-preset-angular": "file:../", + "prettier": "^1.18.2", "protractor": "^5.4.0", "ts-node": "^8.0.3", "tslint": "^5.11.0", diff --git a/example/src/app/inline/inline.spec.ts b/example/src/app/inline/inline.spec.ts new file mode 100644 index 0000000000..4e112f47d1 --- /dev/null +++ b/example/src/app/inline/inline.spec.ts @@ -0,0 +1,54 @@ +import { Component, Input } from "@angular/core"; +import { ComponentFixture, TestBed } from "@angular/core/testing"; + +/** + * Example test component. + */ +@Component({ + selector: "tc-jest-inline-test1", + template: ` +
Line 1
+
+
+ {{ value1 }} +
+ + {{ value2 }} + +
+ ` +}) +export class JestInlineSnapBugComponent { + @Input() value1: string = "val1"; + @Input() value2: string = "val2"; + + condition1: boolean = true; + condition2: boolean = false; +} + +describe("Jest Snapshot Bug", () => { + let comp: JestInlineSnapBugComponent; + let fixture: ComponentFixture; + + beforeEach(() => { + TestBed.configureCompiler({ preserveWhitespaces: false } as any); + TestBed.configureTestingModule({ + declarations: [JestInlineSnapBugComponent] + }); + fixture = TestBed.createComponent(JestInlineSnapBugComponent); + comp = fixture.componentInstance; + fixture.detectChanges(); + }); + + it("should allow snapshots", () => { + expect(fixture).toMatchInlineSnapshot(); + + comp.condition2 = true; + fixture.detectChanges(); + expect(fixture).toMatchInlineSnapshot(); + + comp.condition1 = false; + comp.condition2 = false; + expect(fixture).toMatchInlineSnapshot(); + }); +}); diff --git a/example/yarn.lock b/example/yarn.lock index c148192856..f8893c383d 100644 --- a/example/yarn.lock +++ b/example/yarn.lock @@ -5714,6 +5714,11 @@ prelude-ls@~1.1.2: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= +prettier@^1.18.2: + version "1.18.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea" + integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw== + pretty-format@^24.0.0: version "24.0.0" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-24.0.0.tgz#cb6599fd73ac088e37ed682f61291e4678f48591"