Update jest.config.js
This commit is contained in:
parent
1028613cad
commit
f1c739f2a8
6 changed files with 831 additions and 36 deletions
|
@ -1,7 +1,10 @@
|
||||||
|
const path = require("path");
|
||||||
|
const toptions = { tsconfig: "<rootDir>/etc/tsconfig.json" }
|
||||||
module.exports = {
|
module.exports = {
|
||||||
preset: 'ts-jest',
|
rootDir: path.resolve(__dirname, ".."),
|
||||||
|
transform: { "^.+\\.(ts|tsx)$": ["ts-jest", toptions]},
|
||||||
|
preset: "ts-jest",
|
||||||
testEnvironment: "jsdom",
|
testEnvironment: "jsdom",
|
||||||
"moduleNameMapper": {
|
moduleNameMapper: { "^~/(.*)$": "<rootDir>/src/js/$1" },
|
||||||
"^~/(.*)$": "<rootDir>/src/js/$1"
|
moduleFileExtensions: ["js", "ts", "tsx"],
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
|
"jsxImportSource": "preact",
|
||||||
"lib": [ "ES2020", "DOM" ],
|
"lib": [ "ES2020", "DOM" ],
|
||||||
"baseUrl": "../src/",
|
"baseUrl": "../src/",
|
||||||
"paths": { "~/*": ["js/*"] },
|
"paths": { "~/*": ["js/*"] },
|
||||||
|
|
|
@ -20,7 +20,7 @@ module.exports = {
|
||||||
"react/jsx-runtime": "preact/jsx-runtime",
|
"react/jsx-runtime": "preact/jsx-runtime",
|
||||||
},
|
},
|
||||||
modules: [path.resolve(__dirname, "..", "node_modules")],
|
modules: [path.resolve(__dirname, "..", "node_modules")],
|
||||||
extensions: [".ts", ".tsx"]
|
extensions: [".js", ".ts", ".tsx"]
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
|
@ -30,7 +30,7 @@ module.exports = {
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
options: {
|
options: {
|
||||||
loader: "tsx",
|
loader: "tsx",
|
||||||
target: "es2015"
|
target: "ES5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
839
package-lock.json
generated
839
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -9,11 +9,10 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@testing-library/jest-dom": "^6.4",
|
"@testing-library/jest-dom": "^6.4",
|
||||||
|
"@testing-library/preact": "^3.2.4",
|
||||||
"@testing-library/react": "^16.0",
|
"@testing-library/react": "^16.0",
|
||||||
"@types/chrome": "^0.0.269",
|
"@types/chrome": "^0.0.269",
|
||||||
"@types/jest": "^29.5",
|
"@types/jest": "^29.5",
|
||||||
"@types/react": "^18.3",
|
|
||||||
"@types/react-dom": "^18.3",
|
|
||||||
"clean-webpack-plugin": "^4.0.0",
|
"clean-webpack-plugin": "^4.0.0",
|
||||||
"copy-webpack-plugin": "^12.0",
|
"copy-webpack-plugin": "^12.0",
|
||||||
"esbuild-loader": "^4.2",
|
"esbuild-loader": "^4.2",
|
||||||
|
@ -23,7 +22,7 @@
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"jest-environment-jsdom": "^29.7.0",
|
"jest-environment-jsdom": "^29.7.0",
|
||||||
"prettier": "^3.3",
|
"prettier": "^3.3",
|
||||||
"ts-jest": "^29.2",
|
"ts-jest": "^29.2.5",
|
||||||
"typescript": "^5.5",
|
"typescript": "^5.5",
|
||||||
"typescript-eslint": "^8.0.0",
|
"typescript-eslint": "^8.0.0",
|
||||||
"webpack": "^5.93",
|
"webpack": "^5.93",
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import React from "react";
|
|
||||||
import '@testing-library/jest-dom';
|
import '@testing-library/jest-dom';
|
||||||
import { render, screen, act } from "@testing-library/react";
|
import { render, screen, act } from "@testing-library/preact";
|
||||||
import { App } from "~/components/App";
|
import { App } from "~/components/App";
|
||||||
import { getMessage } from "./mocks/chrome.i18n";
|
import { getMessage } from "./mocks/chrome.i18n";
|
||||||
import { success, error, loading } from "./mocks/fetch";
|
import { success, error, loading } from "./mocks/fetch";
|
||||||
|
@ -33,7 +32,7 @@ describe("App.tsx", () => {
|
||||||
afterEach(() => { global.fetch = globalFetch; });
|
afterEach(() => { global.fetch = globalFetch; });
|
||||||
|
|
||||||
test("response is rendered", async () => {
|
test("response is rendered", async () => {
|
||||||
await act(() => render(<App/>));
|
await act(() => { render(<App/>) });
|
||||||
expect(screen.getByTestId("response")).toBeInTheDocument();
|
expect(screen.getByTestId("response")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -43,7 +42,7 @@ describe("App.tsx", () => {
|
||||||
afterEach(() => { global.fetch = globalFetch; });
|
afterEach(() => { global.fetch = globalFetch; });
|
||||||
|
|
||||||
test("error is rendered", async () => {
|
test("error is rendered", async () => {
|
||||||
await act(() => render(<App/>));
|
await act(() => { render(<App/>) });
|
||||||
expect(screen.getByTestId("error")).toBeInTheDocument();
|
expect(screen.getByTestId("error")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue