diff --git a/bun.lockb b/bun.lockb index e68ce790..5ee10233 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/bunfig.toml b/bunfig.toml new file mode 100644 index 00000000..986e271a --- /dev/null +++ b/bunfig.toml @@ -0,0 +1,2 @@ +[test] +preload = "./happydom.ts" \ No newline at end of file diff --git a/happydom.ts b/happydom.ts new file mode 100644 index 00000000..7f712d02 --- /dev/null +++ b/happydom.ts @@ -0,0 +1,3 @@ +import { GlobalRegistrator } from "@happy-dom/global-registrator"; + +GlobalRegistrator.register(); diff --git a/lib/domains/character/CharacterFactory.test.tsx b/lib/domains/character/CharacterFactory.test.tsx index 67ea26ca..7a996476 100644 --- a/lib/domains/character/CharacterFactory.test.tsx +++ b/lib/domains/character/CharacterFactory.test.tsx @@ -660,7 +660,7 @@ describe("CharacterFactory.duplicate", () => { const characterWithFakeIds = produce(defaultCharacter, (draft) => { draft.id = "1"; - draft.pages.forEach((p) => { + draft.pages?.forEach((p) => { p.id = "1"; p.rows.forEach((r) => { r.columns.forEach((c) => { @@ -677,7 +677,7 @@ describe("CharacterFactory.duplicate", () => { const duplicate = CharacterFactory.duplicate(characterWithFakeIds); expect(duplicate.id).not.toBe("1"); - duplicate.pages.forEach((p) => { + duplicate.pages?.forEach((p) => { expect(p.id).not.toBe("1"); p.rows.forEach((r) => { r.columns.forEach((c) => { diff --git a/lib/domains/character/CharacterFactory.tsx b/lib/domains/character/CharacterFactory.tsx index 62f4a80c..e08660da 100644 --- a/lib/domains/character/CharacterFactory.tsx +++ b/lib/domains/character/CharacterFactory.tsx @@ -94,7 +94,8 @@ export const CharacterFactory = { resetAllIds(character: ICharacter): ICharacter { return produce(character, (draft) => { draft.id = Id.generate(); - draft.pages.forEach((page) => { + + draft.pages?.forEach((page) => { page.id = Id.generate(); page.rows.forEach((row) => { row.columns.forEach((col) => { diff --git a/package.json b/package.json index bdd40bb5..76d67ff1 100644 --- a/package.json +++ b/package.json @@ -17,9 +17,7 @@ "beta": "bun run build && bun run deploy:preview -- --alias beta", "tsc": "tsc --project tsconfig.json --incremental --noEmit", "lint": "eslint 'lib/**' --cache", - "test": "bun test watch", - "test:run": "bun test run", - "test:ui": "bun test watch --ui", + "test": "vitest", "int": "bun run build && concurrently \"cypress run\" \"bun run serve:build\" --success first --kill-others --names \"cypress,server\" ", "int:start": "concurrently \"cypress open\" \"bun run start\" --success first --kill-others --names \"cypress,server\" ", "tsc-and-lint": "bun run tsc && bun run lint", @@ -70,6 +68,7 @@ "uuid": "^9.0.0" }, "devDependencies": { + "@happy-dom/global-registrator": "^11.0.2", "@storybook/addon-essentials": "^7.3.1", "@storybook/addon-interactions": "^7.3.1", "@storybook/addon-links": "^7.3.1", @@ -89,7 +88,7 @@ "@typescript-eslint/parser": "^6.3.0", "@vitejs/plugin-legacy": "^4.1.1", "@vitejs/plugin-react": "^4.0.4", - "@vitest/ui": "^0.34.1", + "bun-types": "^1.0.1", "chromatic": "^6.21.0", "concurrently": "^8.2.0", "cypress": "^12.17.3", @@ -106,8 +105,7 @@ "react-test-renderer": "^18.2.0", "storybook": "^7.3.1", "typescript": "^5.1.6", - "vite": "^4.4.9", - "vitest": "^0.34.1" + "vite": "^4.4.9" }, "lint-staged": { "*.{js,ts,tsx}": "eslint --cache --fix", diff --git a/tsconfig.json b/tsconfig.json index d0c79830..b6de59df 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,7 @@ "name": "typescript-tslint-plugin" } ], - "types": ["vite/client", "vitest/globals"] + "types": ["bun-types", "vitest/globals"] }, "include": ["lib/**/*", "stories/**/*"], "exclude": ["node_modules", "cypress"]