Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move serializers setup to jest config to be possible to override them #126

Merged
merged 1 commit into from
Feb 22, 2018

Conversation

yurii-sorokin
Copy link
Contributor

],
"snapshotSerializers": [
"<rootDir>/node_modules/jest-preset-angular/AngularSnapshotSerializer.js",
"<rootDir>/node_modules/jest-preset-angular/HTMLCommentSerializer.js"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the order be different? Have you tested if that changes anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tried both and seems there is no any difference. Will look how jest applies this config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I bet I've seen something about the order in jest docs, but can't find it now. Anyway, jest reverses the list:

config.snapshotSerializers
    .concat()
    .reverse()
    .forEach(path => {
      addSerializer(localRequire(path));
    });

So it's same as before.

@ahnpnl
Copy link
Collaborator

ahnpnl commented Feb 22, 2018

nice 👍

@thymikee thymikee merged commit e09970a into thymikee:master Feb 22, 2018
@thymikee
Copy link
Owner

published v5.1.0 with this change

@ghost
Copy link

ghost commented Feb 22, 2018 via email

@yurii-sorokin
Copy link
Contributor Author

You can try this serializer that uses the default serializers (built-in plugins for pretty-format). Basically, it transforms component fixture to react test object (mostly, as it does not convert dom nodes needed when using [innerHTML]). Which jest-snapshot understand well.

Or you can write your own serializer, for example, that uses require('util').inspect to serialize fixture or anything you like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants