Open moltar opened 5 years ago
Thank you, these would be useful options. I'll be able to get back on this after holidays. I am open to PRs if you can come up with a solution.
Any update on this? I would be more interested on a naming scheme similar to Jest snapshots...
That actually gives me an idea... Why not just use snapshots internally? Can we reach into jest internals and call the snapshot method to store the nocks?
@moltar jest-snapshot
is its own package and exposes the methods used in the jest assertion API https://github.com/facebook/jest/blob/master/packages/jest-snapshot/src/index.ts#L469. So this could be used?
That package still feels internal-ish and not documented. But it is good that it is a separate package at least!
I guess the only feature needed is the one that reads and writes a spanshot.
It is not immediately clear from that package if it has that kind of interface.
The snapshot setup is exposed via jasmine globals https://github.com/facebook/jest/blob/5816a575889579b2d9f610fb4e2bdf0020e3245d/packages/jest-jasmine2/src/setup_jest_globals.ts#L104, couldn't find how to actually use it though. But the assertions are global as well, so maybe we can just use expect.toMatchSnapshot
? Will be updated whenever updating other snapshots, not sure if that makes sense.
Will be updated whenever updating other snapshots, not sure if that makes sense.
It does, in fact that was my expected behaviour. Snapshots gets updated when they fail because got obsoleted and user requested to regenerate them, this could also regenerate the snapshots for jest-nock
... just only that user would not get a failure if they get obsolete because they are not snapshots of current code but fixtures for external services.
First of all, great module, thanks for your work!
Would be great to be able to generate a custom filename.
For example, I'd like to be able to use group names and test name combo. And instead of
djb2
to use a SHA hash.Thank you.