You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had a case where I tried to check that a function was called with an object that contained a key whose value was a snapshotted string, so I used one of the "satisfying" assertions in -sinon. The following is a simplified reproduction case:
constexpect=require("unexpected").clone().use(require("unexpected-snapshot"));constmakeSomeStuff=()=>"foo bar baz\nbaz bar foo";it("should work",()=>{expect([{stuff: makeSomeStuff()}],"to satisfy",[{stuff: expect.it("to equal snapshot")}]);});
Running mocha on the above in snapshot update mode as-is, I receive the following TypeError:
TypeError: Cannot read property 'replace' of undefined
at fixUnexpected (node_modules/unexpected-snapshot/lib/applyFixes.js:87:62)
at Traverser.enter [as _enter] (node_modules/unexpected-snapshot/lib/applyFixes.js:209:26)
If I force the insertion point by modifying the expect.it to read expect.it('to equal snapshot', '') it gets further, but the injection of the snapshot removes the nested spec structure on the RHS and instead injects at the top level resulting in:
The text was updated successfully, but these errors were encountered:
alexjeffburke
changed the title
Issues using snapshots with expect.it() in a nested structure
Issues using snapshots with expect.it() in a nested structure
Apr 13, 2020
unexpected-snapshot does not support expect.it at the moment. It'll be rather tricky, so we decided to leave it out initially. Would be nice if it failed a bit more gracefully, though.
@papandreou I confess that I wasn't aware this wasn't intended to work per se, and choosing to show a clear message in this case is a really good shout - keep the user informed etc.
I'll try the change in situ so I get some perspective on encountering it in person but otherwise I think we can say this is addressed. And we can already revisit if/when we tackle it.
I had a case where I tried to check that a function was called with an object that contained a key whose value was a snapshotted string, so I used one of the "satisfying" assertions in
-sinon
. The following is a simplified reproduction case:Running mocha on the above in snapshot update mode as-is, I receive the following
TypeError
:If I force the insertion point by modifying the expect.it to read
expect.it('to equal snapshot', '')
it gets further, but the injection of the snapshot removes the nested spec structure on the RHS and instead injects at the top level resulting in:The text was updated successfully, but these errors were encountered: