Skip to content

Commit

Permalink
test: add unit tests
Browse files Browse the repository at this point in the history
Migrate test runner to Vitest since Jest has experimental support for ESM.
  • Loading branch information
jamesgeorge007 committed Jun 5, 2024
1 parent b29b3ff commit 9596af1
Show file tree
Hide file tree
Showing 38 changed files with 2,125 additions and 525 deletions.
193 changes: 0 additions & 193 deletions packages/hoppscotch-cli/jest.config.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/hoppscotch-cli/jest.setup.ts

This file was deleted.

8 changes: 3 additions & 5 deletions packages/hoppscotch-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"debugger": "node debugger.js 9999",
"prepublish": "pnpm exec tsup",
"prettier-format": "prettier --config .prettierrc 'src/**/*.ts' --write",
"test": "pnpm run build && jest && rm -rf dist",
"test": "pnpm run build && vitest run && rm -rf dist",
"do-typecheck": "pnpm exec tsc --noEmit",
"do-test": "pnpm test"
},
Expand Down Expand Up @@ -55,15 +55,13 @@
"@hoppscotch/js-sandbox": "workspace:^",
"@relmify/jest-fp-ts": "2.1.1",
"@swc/core": "1.4.2",
"@types/jest": "29.5.12",
"@types/lodash-es": "4.17.12",
"@types/qs": "6.9.12",
"fp-ts": "2.16.2",
"jest": "29.7.0",
"prettier": "3.2.5",
"qs": "6.11.2",
"ts-jest": "29.1.2",
"tsup": "8.0.2",
"typescript": "5.3.3"
"typescript": "5.3.3",
"vitest": "0.34.6"
}
}
15 changes: 15 additions & 0 deletions packages/hoppscotch-cli/setupFiles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Vitest doesn't work without globals
// Ref: https://github.com/relmify/jest-fp-ts/issues/11

import decodeMatchers from "@relmify/jest-fp-ts/dist/decodeMatchers";
import eitherMatchers from "@relmify/jest-fp-ts/dist/eitherMatchers";
import optionMatchers from "@relmify/jest-fp-ts/dist/optionMatchers";
import theseMatchers from "@relmify/jest-fp-ts/dist/theseMatchers";
import eitherOrTheseMatchers from "@relmify/jest-fp-ts/dist/eitherOrTheseMatchers";
import { expect } from "vitest";

expect.extend(decodeMatchers.matchers);
expect.extend(eitherMatchers.matchers);
expect.extend(optionMatchers.matchers);
expect.extend(theseMatchers.matchers);
expect.extend(eitherOrTheseMatchers.matchers);

0 comments on commit 9596af1

Please sign in to comment.