Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/internal/test_runner/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ class SnapshotManager {
);
}

this.snapshots = context.exports;
for (const key in context.exports) {
this.snapshots[key] = templateEscape(context.exports[key]);
}
this.loaded = true;
} catch (err) {
let msg = `Cannot read snapshot file '${this.snapshotFile}.'`;
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/test-runner/snapshots/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ test('`${foo}`', async (t) => {
const options = { serializers: [() => { return '***'; }]};
t.assert.snapshot('snapshotted string', options);
});

test('escapes in `\\${foo}`\n', async (t) => {
t.assert.snapshot('`\\${foo}`\n');
});
12 changes: 6 additions & 6 deletions test/parallel/test-runner-snapshot-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,9 @@ test('t.assert.snapshot()', async (t) => {

t.assert.strictEqual(child.code, 1);
t.assert.strictEqual(child.signal, null);
t.assert.match(child.stdout, /# tests 3/);
t.assert.match(child.stdout, /# tests 4/);
t.assert.match(child.stdout, /# pass 0/);
t.assert.match(child.stdout, /# fail 3/);
t.assert.match(child.stdout, /# fail 4/);
t.assert.match(child.stdout, /Missing snapshots/);
});

Expand All @@ -311,8 +311,8 @@ test('t.assert.snapshot()', async (t) => {

t.assert.strictEqual(child.code, 0);
t.assert.strictEqual(child.signal, null);
t.assert.match(child.stdout, /tests 3/);
t.assert.match(child.stdout, /pass 3/);
t.assert.match(child.stdout, /tests 4/);
t.assert.match(child.stdout, /pass 4/);
t.assert.match(child.stdout, /fail 0/);
});

Expand All @@ -325,8 +325,8 @@ test('t.assert.snapshot()', async (t) => {

t.assert.strictEqual(child.code, 0);
t.assert.strictEqual(child.signal, null);
t.assert.match(child.stdout, /tests 3/);
t.assert.match(child.stdout, /pass 3/);
t.assert.match(child.stdout, /tests 4/);
t.assert.match(child.stdout, /pass 4/);
t.assert.match(child.stdout, /fail 0/);
});
});