Skip to content

Commit cded6b0

Browse files
refactor: separate tests into own module (#371)
* refactor: separate tests into own module I've also tried to keep the numbers of imported types down so there's less chance of duplicate declarations. Finally, the Enzyme types seem a little broken, so I declared them. We only use a single method, so it seems fine for now. * fix: use node 22's types
1 parent 4d23403 commit cded6b0

28 files changed

+131
-87
lines changed

base-tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"skipLibCheck": true,
1111
"sourceMap": true,
1212
"strict": true,
13-
"target": "ES2024",
14-
"types": ["vitest/globals"]
13+
"types": [],
14+
"target": "ES2024"
1515
}
1616
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@
103103
"license": "BSD-3-Clause",
104104
"dependencies": {
105105
"@sinonjs/fake-timers": "^14.0.0",
106-
"@types/enzyme": "^3.10.19",
107-
"@types/enzyme-adapter-react-16": "^1.0.9",
108106
"@types/jquery": "^3.5.32",
107+
"@types/react": "^19.1.8",
108+
"@types/react-dom": "^19.1.6",
109109
"@types/sinonjs__fake-timers": "^8.1.5",
110110
"browserify": "^17.0.0",
111111
"chai": "4",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
declare module "enzyme" {
2+
interface ConfigureOptions {
3+
adapter: object;
4+
}
5+
6+
export function configure(options: ConfigureOptions): void;
7+
}
8+
9+
declare module "enzyme-adapter-react-16" {
10+
class Adapter {
11+
constructor();
12+
}
13+
14+
export default Adapter;
15+
}

packages/dom-evaluator/src/dom-test-evaluator.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,12 @@ const READY_MESSAGE: ReadyEvent["data"] = { type: "ready" };
2727

2828
declare global {
2929
var __FakeTimers: typeof FakeTimers;
30-
// @ts-expect-error chai is not accessible in the global scope
3130
var assert: typeof chaiAssert;
3231
}
3332

3433
// @ts-expect-error jQuery cannot be declared.
3534
globalThis.$ = jQuery;
36-
// @ts-expect-error somehow importing Enzyme makes TS think you cannot modify globalThis
3735
globalThis.__FakeTimers = FakeTimers;
38-
// @ts-expect-error somehow importing Enzyme makes TS think you cannot modify globalThis
3936
globalThis.assert = chaiAssert;
4037

4138
// Local storage is not accessible in a sandboxed iframe, so we need to mock it

packages/helpers/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"extends": "../../base-tsconfig.json",
3-
"exclude": ["**/__tests__", "**/__fixtures__", "**/__mocks__"],
43
"compilerOptions": {
54
"rootDir": "./",
65
"declarationDir": "../../dist/types/helpers",

packages/javascript-evaluator/src/javascript-test-evaluator.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { ProxyConsole, createLogFlusher } from "../../shared/src/proxy-console";
1717

1818
const READY_MESSAGE: ReadyEvent["data"] = { type: "ready" };
1919
declare global {
20-
// @ts-expect-error chai is not accessible in the global scope, but TS thinks it is
2120
var assert: typeof chaiAssert;
2221
var __helpers: typeof curriculumHelpers;
2322
}

packages/shared/package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "@freecodecamp/shared",
3+
"description": "Shared modules.",
4+
"private": true,
5+
"engines": {
6+
"pnpm": ">= 10"
7+
},
8+
"scripts": {},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+ssh://git@github.com/freeCodeCamp/curriculum-helpers.git"
12+
},
13+
"license": "BSD-3-Clause",
14+
"dependencies": {
15+
"@types/node": "^22.15.34"
16+
}
17+
}

packages/shared/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"compilerOptions": {
44
"lib": ["DOM", "ESNext"],
55
"rootDir": "./",
6+
"types": ["node"],
67
"declarationDir": "../../dist/types/shared",
78
"outDir": "./build",
89
"tsBuildInfoFile": ".tsbuildinfo"

packages/helpers/lib/__fixtures__/curriculum-helper-css.ts renamed to packages/tests/__fixtures__/curriculum-helper-css.ts

File renamed without changes.

packages/helpers/lib/__fixtures__/curriculum-helpers-html.ts renamed to packages/tests/__fixtures__/curriculum-helpers-html.ts

File renamed without changes.

0 commit comments

Comments
 (0)