-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed as not planned
Labels
Description
🐛 Bug Report
When I try to add a test with an inline snapshot:
it('works with inline snapshots', () => {
expect({a: 1}).toMatchInlineSnapshot();
});
I get this error:
Jest: Couldn't locate all inline snapshots.
I can't repro this in repl.it because that version does not have inline snapshots yet:
TypeError: expect(...).toMatchInlineSnapshot is not a function
I cloned the github repo and added a test to inline_snapshots.test.js
test('saveInlineSnapshots() replaces empty function call with a template literal for objects', () => {
const filename = path.join(__dirname, 'my.test.js');
fs.readFileSync = (jest.fn(
() => `expect({a: 'a'}).toMatchInlineSnapshot();\n`,
): any);
saveInlineSnapshots(
[
{
frame: {column: 11, file: filename, line: 1},
snapshot: `{a: 'a'}`,
},
],
prettier,
babelTraverse,
);
expect(fs.writeFileSync).toHaveBeenCalledWith(
filename,
"expect({a: 'a'}).toMatchInlineSnapshot(`{a: 'a'}`);\n",
);
});
and this reproes the issue:
FAIL packages/jest-snapshot/src/__tests__/inline_snapshots.test.js
✓ saveInlineSnapshots() replaces empty function call with a template literal (67ms)
✕ saveInlineSnapshots() replaces empty function call with a template literal for objects (19ms)
✓ saveInlineSnapshots() replaces existing template literal - babylon parser (4ms)
✓ saveInlineSnapshots() replaces existing template literal - flow parser (2ms)
✓ saveInlineSnapshots() replaces existing template literal - typescript parser (2ms)
✓ saveInlineSnapshots() replaces existing template literal with property matchers (3ms)
✓ saveInlineSnapshots() throws if frame does not match (2ms)
✓ saveInlineSnapshots() throws if multiple calls to to the same location (2ms)
✓ saveInlineSnapshots() uses escaped backticks (2ms)
● saveInlineSnapshots() replaces empty function call with a template literal for objects
Jest: Couldn't locate all inline snapshots.
at Object.parse (packages/jest-snapshot/src/inline_snapshots.js:168:11)
WesSouza, silvenon, aleclarson, eps1lon, kalyan-anna and 6 more