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
8 changes: 6 additions & 2 deletions e2e/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import slash from 'slash';
import which from 'which';
import type {Config} from '@pkg-nec/jest-types';

const dedent = dedentBase.withOptions({escapeSpecialCharacters: true});
// File contents are already evaluated JavaScript strings. Preserve escape
// sequences such as `\b` and `\r` instead of decoding them a second time.
const dedent = dedentBase.withOptions({escapeSpecialCharacters: false});

export const run = (
cmd: string,
Expand Down Expand Up @@ -129,6 +131,7 @@ export const cleanup = (directory: string) => {
export const writeFiles = (
directory: string,
files: {[filename: string]: string},
options?: {trailingNewline?: boolean},
) => {
fs.mkdirSync(directory, {recursive: true});
for (const fileOrPath of Object.keys(files)) {
Expand All @@ -137,9 +140,10 @@ export const writeFiles = (
if (dirname !== '/') {
fs.mkdirSync(path.join(directory, dirname), {recursive: true});
}
const contents = dedent(files[fileOrPath]);
fs.writeFileSync(
path.resolve(directory, ...fileOrPath.split('/')),
dedent(files[fileOrPath]),
options?.trailingNewline ? `${contents}\n` : contents,
);
}
};
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/toMatchInlineSnapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,10 @@ test('indentation is correct in the presences of existing snapshots, when the fi
it('is true', () => {
expect(true).toMatchInlineSnapshot(\`true\`);
expect([1, 2, 3]).toMatchInlineSnapshot();
});\\n
});
`;

writeFiles(TESTS_DIR, {[filename]: test});
writeFiles(TESTS_DIR, {[filename]: test}, {trailingNewline: true});
const {stderr, exitCode} = runJest(DIR, ['-w=1', '--ci=false', filename]);
const fileAfter = readFile(filename);
expect(stderr).toMatch('1 snapshot written from 1 test suite.');
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
"@eslint/js": "^9.28.0",
"@eslint/markdown": "^8.0.0",
"@lerna-lite/cli": "^4.3.0",
"@lerna-lite/exec": "^4.3.0",
"@lerna-lite/publish": "^4.3.0",
"@lerna-lite/cli": "^4.11.5",
"@lerna-lite/exec": "^4.11.5",
"@lerna-lite/publish": "^4.11.5",
"@microsoft/api-extractor": "^7.35.0",
"@pkg-nec/babel-jest": "workspace:*",
"@pkg-nec/jest": "workspace:*",
Expand All @@ -38,7 +38,7 @@
"babel-loader": "^9.2.1",
"camelcase": "^6.3.0",
"chalk": "^4.1.2",
"dedent": "^1.6.0",
"dedent": "^1.7.2",
"eslint": "^9.28.0",
"eslint-config-prettier": "^10.1.5",
"eslint-import-resolver-typescript": "^4.4.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-circus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@types/node": "*",
"chalk": "^4.1.2",
"co": "^4.6.0",
"dedent": "^1.6.0",
"dedent": "^1.7.2",
"is-generator-fn": "^2.1.0",
"p-limit": "^3.1.0",
"pure-rand": "^7.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@types/graceful-fs": "^4.1.9",
"@types/node": "*",
"@types/parse-json": "^4.0.2",
"esbuild": "^0.28.0",
"esbuild": "^0.28.1",
"esbuild-register": "^3.6.0",
"semver": "^7.7.2",
"ts-node": "^10.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-transform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@types/convert-source-map": "^2.0.3",
"@types/graceful-fs": "^4.1.9",
"@types/write-file-atomic": "^4.0.3",
"dedent": "^1.6.0"
"dedent": "^1.7.2"
},
"engines": {
"node": "^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0"
Expand Down
Loading
Loading