question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Different snapshot with --coverage

See original GitHub issue

I am currently using jest-preset-angular@7.0.0-alpha.2 and our CI builds started to failing due to different snapshot when using jest with --coverage:

-                   ng-reflect-product-filter="function (product) { return pr"
+                   ng-reflect-product-filter="function (product) {
+            "

This started to happend when I upgraded to version 7 which uses ts-jest. Not sure who is responsible for serializing components. There is similar issue, but I don’t see anything related to istanbul in my snapshot.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Ludevikcommented, Jan 20, 2019

@thymikee this was just simplest example i could think of. In my real setup i don’t serialize the function to html directly, but it is an @Input to other component and serialization is just side effect. It looks something like this:

@Component({
	selector: 'test',
	template: '<child-component [predicate]="predicate"></child-component>'
})
class TestComponent {
    get predicate(): () => boolean {
        return Predicates.doSomething;
    }
}

Current behaviour doesn’t allow to snapshot test a component which uses some other component with function @Inputs when used together with coverage. There are currently component libraries out there which use functions as inputs.

I’ll try to write the serializer and see how far i can get 😉

0reactions
thymikeecommented, May 17, 2019

@Ludevik always learning, that’s the attitude! I could’ve at least pushed the tag but forgot about it as I made a release during my time off 😅

Read more comments on GitHub >

github_iconTop Results From Across the Web

Snapshot Testing - Jest
Also, rendering the same component with different props in other snapshot tests will not affect the first one, as the tests don't know...
Read more >
Different snapshot in coverage mode #1209 - GitHub
When running in jest 'coverage' mode, the generated snapshot is <div><h1>parent</h1> <child-stub items="1,string,() => { /* istanbul ignore next ...
Read more >
Why jest snapshots can be harmful — practical examples
The snapshot file is long, with a lot of HTML code, and the coverage report doesn't reveal any issues. Let's look at another...
Read more >
Snapshot | Guide - Vitest
Learn Snapshot by video from Vue School. Snapshot tests are a very useful tool whenever you want to make sure the output of...
Read more >
Creating snapshots in Jest for testing React applications
The following image illustrates the process of snapshot testing in Jest. It shows the different outcomes when a snapshot passes, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found