Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update Jest #7220

Merged
merged 1 commit into from
Aug 29, 2023
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
7 changes: 5 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('@jest/types').Config.InitialOptions} */
/** @type {import('jest').Config} */
module.exports = {
modulePathIgnorePatterns: [
"<rootDir>/.tmp",
Expand All @@ -23,10 +23,13 @@ module.exports = {
"packages/remix-server-runtime",
"packages/remix-testing",
],
reporters:
process.env.GITHUB_ACTIONS === null
? ["default"]
Copy link

@SimenB SimenB Aug 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be == - env variables that aren't set are undefined, not null.

 $ node -p 'process.env.SOMETHING_RANDOM === null'
false

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 517e40b

: [["github-actions", { silent: false }], "summary"],
watchPlugins: [
require.resolve("jest-watch-select-projects"),
require.resolve("jest-watch-typeahead/filename"),
require.resolve("jest-watch-typeahead/testname"),
],
reporters: ["default"],
};
18 changes: 14 additions & 4 deletions jest/jest.config.shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,26 @@ const ignorePatterns = [
"\\/\\.tmp\\/",
"\\/\\.cache\\/",
];
/** @type {import('@jest/types').Config.InitialOptions} */

/** @type {import('jest').Config} */
module.exports = {
testEnvironment: "node",
moduleNameMapper: {
"^@remix-run/web-blob$": require.resolve("@remix-run/web-blob"),
"^@remix-run/web-fetch$": require.resolve("@remix-run/web-fetch"),
"^@remix-run/web-file": require.resolve("@remix-run/web-file"),
"^@remix-run/web-form-data$": require.resolve("@remix-run/web-form-data"),
"^@remix-run/web-stream$": require.resolve("@remix-run/web-stream"),
"^@web3-storage/multipart-parser$": require.resolve(
"@web3-storage/multipart-parser"
),
},
modulePathIgnorePatterns: ignorePatterns,
watchPathIgnorePatterns: [...ignorePatterns, "\\/node_modules\\/"],
testMatch: ["<rootDir>/**/*-test.[jt]s?(x)"],
setupFiles: ["<rootDir>/__tests__/setup.ts"],
testMatch: ["<rootDir>/**/*-test.[jt]s?(x)"],
transform: {
"\\.[jt]sx?$": require.resolve("./transform"),
},
watchPathIgnorePatterns: [...ignorePatterns, "\\/node_modules\\/"],
watchPlugins: [
require.resolve("jest-watch-select-projects"),
require.resolve("jest-watch-typeahead/filename"),
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
"watch": "rollup -c --watch --watch.onEnd=\"node scripts/copy-build-to-dist.mjs\"",
"postinstall": "patch-package"
},
"resolutions": {
"jsdom": "^22.0.0"
},
"dependencies": {
"@babel/core": "^7.21.8",
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
Expand All @@ -74,7 +77,7 @@
"@types/cross-spawn": "^6.0.2",
"@types/dedent": "^0.7.0",
"@types/glob": "7.2.0",
"@types/jest": "^27.4.1",
"@types/jest": "^29.5.4",
"@types/jsonfile": "^6.1.0",
"@types/lodash": "^4.14.182",
"@types/react": "^18.2.20",
Expand All @@ -84,7 +87,7 @@
"@types/semver": "^7.3.4",
"@types/serialize-javascript": "^5.0.2",
"@types/ssri": "^7.1.0",
"babel-jest": "^27.5.1",
"babel-jest": "^29.6.4",
"babel-plugin-transform-remove-console": "^6.9.4",
"chalk": "^4.1.2",
"concurrently": "^7.0.0",
Expand All @@ -95,9 +98,9 @@
"eslint-plugin-prefer-let": "^3.0.1",
"front-matter": "^4.0.2",
"glob": "8.0.3",
"jest": "^27.5.1",
"jest": "^29.6.4",
"jest-watch-select-projects": "^2.0.0",
"jest-watch-typeahead": "^0.6.5",
"jest-watch-typeahead": "^2.2.2",
"jsonfile": "^6.0.1",
"lodash": "^4.17.21",
"mime": "^3.0.0",
Expand Down
16 changes: 8 additions & 8 deletions packages/create-remix/__tests__/create-remix-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ describe("create-remix CLI", () => {
});

expect(stderr.trim()).toMatchInlineSnapshot(
`"▲ Oh no! The path \\"this/path/does/not/exist\\" was not found in this GitHub repo."`
MichaelDeBoey marked this conversation as resolved.
Show resolved Hide resolved
`"▲ Oh no! The path "this/path/does/not/exist" was not found in this GitHub repo."`
);
expect(status).toBe(1);
expect(fse.existsSync(path.join(projectDir, "package.json"))).toBeFalsy();
Expand Down Expand Up @@ -381,7 +381,7 @@ describe("create-remix CLI", () => {
});

expect(stderr.trim()).toMatchInlineSnapshot(
`"▲ Oh no! The path \\"this/path/does/not/exist\\" was not found in this GitHub repo."`
`"▲ Oh no! The path "this/path/does/not/exist" was not found in this GitHub repo."`
);
expect(status).toBe(1);
expect(fse.existsSync(path.join(projectDir, "package.json"))).toBeFalsy();
Expand Down Expand Up @@ -1086,12 +1086,12 @@ describe("create-remix CLI", () => {
});

expect(stderr.trim()).toMatchInlineSnapshot(`
"▲ Oh no! Destination directory contains files that would be overwritten
and no \`--overwrite\` flag was included in a non-interactive
environment. The following files would be overwritten:
package.json
tsconfig.json"
`);
"▲ Oh no! Destination directory contains files that would be overwritten
and no \`--overwrite\` flag was included in a non-interactive
environment. The following files would be overwritten:
package.json
tsconfig.json"
`);
expect(status).toBe(1);
expect(
fse.existsSync(path.join(projectDir, "app/root.tsx"))
Expand Down
2 changes: 1 addition & 1 deletion packages/create-remix/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('@jest/types').Config.InitialOptions} */
/** @type {import('jest').Config} */
module.exports = {
...require("../../jest/jest.config.shared"),
displayName: "create-remix",
Expand Down
4 changes: 1 addition & 3 deletions packages/remix-architect/__tests__/server-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,7 @@ describe("architect createRemixHeaders", () => {
describe("creates fetch headers from architect headers", () => {
it("handles empty headers", () => {
let headers = createRemixHeaders({});
expect(Object.fromEntries(headers.entries())).toMatchInlineSnapshot(
`Object {}`
);
expect(Object.fromEntries(headers.entries())).toMatchInlineSnapshot(`{}`);
});

it("handles simple headers", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-architect/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('@jest/types').Config.InitialOptions} */
/** @type {import('jest').Config} */
module.exports = {
...require("../../jest/jest.config.shared"),
displayName: "architect",
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/__tests__/cli-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe("remix CLI", () => {
Run your project locally in development:

$ remix dev
$ remix dev -c \\"node ./server.js\\"
$ remix dev -c "node ./server.js"

Start your server separately and watch for changes:

Expand Down
52 changes: 26 additions & 26 deletions packages/remix-dev/__tests__/cssSideEffectImports-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("addSuffixToCssSideEffectImports", () => {
`;

expect(addSuffixToCssSideEffectImports("js", code)).toMatchInlineSnapshot(
`"require(\\"./foo.css?__remix_sideEffect__\\");"`
`"require("./foo.css?__remix_sideEffect__");"`
);
});

Expand All @@ -20,7 +20,7 @@ describe("addSuffixToCssSideEffectImports", () => {
`;

expect(addSuffixToCssSideEffectImports("js", code)).toMatchInlineSnapshot(
`"import \\"./foo.css?__remix_sideEffect__\\";"`
`"import "./foo.css?__remix_sideEffect__";"`
);
});

Expand All @@ -33,7 +33,7 @@ describe("addSuffixToCssSideEffectImports", () => {

expect(addSuffixToCssSideEffectImports("jsx", code))
.toMatchInlineSnapshot(`
"import \\"./foo.css?__remix_sideEffect__\\";
"import "./foo.css?__remix_sideEffect__";

export const Foo = () => <div />;"
`);
Expand All @@ -48,7 +48,7 @@ describe("addSuffixToCssSideEffectImports", () => {

expect(addSuffixToCssSideEffectImports("ts", code))
.toMatchInlineSnapshot(`
"require(\\"./foo.css?__remix_sideEffect__\\");
"require("./foo.css?__remix_sideEffect__");

export const foo: string = ('foo' satisfies string);"
`);
Expand All @@ -64,7 +64,7 @@ describe("addSuffixToCssSideEffectImports", () => {

expect(addSuffixToCssSideEffectImports("tsx", code))
.toMatchInlineSnapshot(`
"require(\\"./foo.css?__remix_sideEffect__\\");
"require("./foo.css?__remix_sideEffect__");

export const foo: string = ('foo' satisfies string);
export const Bar = () => <div>{foo}</div>;"
Expand All @@ -82,10 +82,10 @@ describe("addSuffixToCssSideEffectImports", () => {

expect(addSuffixToCssSideEffectImports("js", code))
.toMatchInlineSnapshot(`
"if (process.env.NODE_ENV === \\"production\\") {
require(\\"./foo.min.css?__remix_sideEffect__\\");
"if (process.env.NODE_ENV === "production") {
require("./foo.min.css?__remix_sideEffect__");
} else {
require(\\"./foo.css?__remix_sideEffect__\\");
require("./foo.css?__remix_sideEffect__");
}"
`);
});
Expand All @@ -96,7 +96,7 @@ describe("addSuffixToCssSideEffectImports", () => {
`;

expect(addSuffixToCssSideEffectImports("js", code)).toMatchInlineSnapshot(
`"process.env.NODE_ENV === \\"production\\" ? require(\\"./foo.min.css?__remix_sideEffect__\\") : require(\\"./foo.css?__remix_sideEffect__\\");"`
`"process.env.NODE_ENV === "production" ? require("./foo.min.css?__remix_sideEffect__") : require("./foo.css?__remix_sideEffect__");"`
);
});

Expand All @@ -106,7 +106,7 @@ describe("addSuffixToCssSideEffectImports", () => {
`;

expect(addSuffixToCssSideEffectImports("js", code)).toMatchInlineSnapshot(
`"process.env.NODE_ENV === \\"development\\" && require(\\"./debug.css?__remix_sideEffect__\\");"`
`"process.env.NODE_ENV === "development" && require("./debug.css?__remix_sideEffect__");"`
);
});

Expand All @@ -116,7 +116,7 @@ describe("addSuffixToCssSideEffectImports", () => {
`;

expect(addSuffixToCssSideEffectImports("js", code)).toMatchInlineSnapshot(
`"process.env.NODE_ENV === \\"production\\" || require(\\"./debug.css?__remix_sideEffect__\\");"`
`"process.env.NODE_ENV === "production" || require("./debug.css?__remix_sideEffect__");"`
);
});
});
Expand All @@ -128,7 +128,7 @@ describe("addSuffixToCssSideEffectImports", () => {
`;

expect(addSuffixToCssSideEffectImports("js", code)).toMatchInlineSnapshot(
`"const href = require(\\"./foo.css\\");"`
`"const href = require("./foo.css");"`
);
});

Expand All @@ -138,7 +138,7 @@ describe("addSuffixToCssSideEffectImports", () => {
`;

expect(addSuffixToCssSideEffectImports("js", code)).toMatchInlineSnapshot(
`"import href from \\"./foo.css\\";"`
`"import href from "./foo.css";"`
);
});

Expand All @@ -148,7 +148,7 @@ describe("addSuffixToCssSideEffectImports", () => {
`;

expect(addSuffixToCssSideEffectImports("js", code)).toMatchInlineSnapshot(
`"import { foo } from \\"./foo.css\\";"`
`"import { foo } from "./foo.css";"`
);
});

Expand All @@ -158,7 +158,7 @@ describe("addSuffixToCssSideEffectImports", () => {
`;

expect(addSuffixToCssSideEffectImports("js", code)).toMatchInlineSnapshot(
`"import * as foo from \\"./foo.css\\";"`
`"import * as foo from "./foo.css";"`
);
});

Expand All @@ -171,9 +171,9 @@ describe("addSuffixToCssSideEffectImports", () => {

expect(addSuffixToCssSideEffectImports("js", code))
.toMatchInlineSnapshot(`
"const href = process.env.NODE_ENV === \\"production\\" ?
require(\\"./foo.min.css\\") :
require(\\"./foo.css\\");"
"const href = process.env.NODE_ENV === "production" ?
require("./foo.min.css") :
require("./foo.css");"
`);
});

Expand All @@ -183,7 +183,7 @@ describe("addSuffixToCssSideEffectImports", () => {
`;

expect(addSuffixToCssSideEffectImports("js", code)).toMatchInlineSnapshot(
`"const href = process.env.NODE_ENV === \\"production\\" && require(\\"./foo.min.css\\") || require(\\"./foo.css\\");"`
`"const href = process.env.NODE_ENV === "production" && require("./foo.min.css") || require("./foo.css");"`
);
});

Expand All @@ -193,7 +193,7 @@ describe("addSuffixToCssSideEffectImports", () => {
`;

expect(addSuffixToCssSideEffectImports("js", code)).toMatchInlineSnapshot(
`"require(\\"./foo\\");"`
`"require("./foo");"`
);
});

Expand All @@ -203,7 +203,7 @@ describe("addSuffixToCssSideEffectImports", () => {
`;

expect(addSuffixToCssSideEffectImports("js", code)).toMatchInlineSnapshot(
`"import \\"./foo\\";"`
`"import "./foo";"`
);
});

Expand All @@ -217,7 +217,7 @@ describe("addSuffixToCssSideEffectImports", () => {
expect(addSuffixToCssSideEffectImports("js", code))
.toMatchInlineSnapshot(`
"export const foo = async () => {
await import(\\"./foo.css\\");
await import("./foo.css");
};"
`);
});
Expand Down Expand Up @@ -288,7 +288,7 @@ describe("addSuffixToCssSideEffectImports", () => {

expect(addSuffixToCssSideEffectImports("js", code))
.toMatchInlineSnapshot(`
"require(\\"./foo.css?__remix_sideEffect__\\");
"require("./foo.css?__remix_sideEffect__");

// JS
const topLevelAwait = await Promise.resolve('top level await');
Expand Down Expand Up @@ -330,7 +330,7 @@ describe("addSuffixToCssSideEffectImports", () => {

expect(addSuffixToCssSideEffectImports("jsx", code))
.toMatchInlineSnapshot(`
"require(\\"./foo.css?__remix_sideEffect__\\");
"require("./foo.css?__remix_sideEffect__");

// JSX
const ExampleComponent = () => <div>JSX element</div>;
Expand Down Expand Up @@ -375,7 +375,7 @@ describe("addSuffixToCssSideEffectImports", () => {

expect(addSuffixToCssSideEffectImports("tsx", code))
.toMatchInlineSnapshot(`
"require(\\"./foo.css?__remix_sideEffect__\\");
"require("./foo.css?__remix_sideEffect__");

// TS
const exampleSatisfies = ('satisfies' satisfies string);
Expand Down Expand Up @@ -425,7 +425,7 @@ describe("addSuffixToCssSideEffectImports", () => {

expect(addSuffixToCssSideEffectImports("tsx", code))
.toMatchInlineSnapshot(`
"require(\\"./foo.css?__remix_sideEffect__\\");
"require("./foo.css?__remix_sideEffect__");

// TS
const exampleSatisfies = ('satisfies' satisfies string);
Expand Down
Loading
Loading