Skip to content

Commit

Permalink
Add Jest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robmosca committed Jun 26, 2023
1 parent 052d1a1 commit cfdbd2e
Show file tree
Hide file tree
Showing 9 changed files with 4,070 additions and 1,551 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build and Test

on:
push:
branches: main
pull_request:
branches: "*"

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: "16"
- uses: pnpm/[email protected]
with:
version: 8.4.0
- run: git checkout main && git checkout $GITHUB_SHA
- run: pnpm install --frozen-lockfile
- run: pnpm run build
- run: pnpm run lint
- run: pnpm run test-jest
9 changes: 9 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import('jest').Config} */
const config = {
testEnvironment: "jsdom",
resetMocks: true,
restoreMocks: true,
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
};

module.exports = config;
4 changes: 4 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { TextEncoder, TextDecoder } from "util";

global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"clean": "rimraf dist",
"watch": "cross-env NODE_ENV=development rollup -c --watch",
"copy-test-files": "copyfiles test/**/* dist -f",
"test-jest": "jest",
"test-serve": "serve .",
"test-embed-serve": "serve . -l 3333",
"test": "concurrently pnpm:watch pnpm:copy-test-files pnpm:test-serve pnpm:test-embed-serve",
Expand Down Expand Up @@ -43,16 +44,20 @@
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-node-resolve": "^13.0.2",
"concurrently": "^6.2.0",
"copyfiles": "^2.3.0",
"cross-env": "^7.0.2",
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
"eslint": "^7.31.0",
"eslint-config-important-stuff": "^1.1.0",
"eslint-plugin-es5": "^1.5.0",
"husky": "^7.0.0",
"husky": "^7.0.1",
"jest": "^29.5.0",
"jest-cli": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"postcss": "^8.3.5",
"preact": "^10.5.14",
"prettier": "^2.3.2",
"pretty-quick": "^3.1.1",
"regenerator-runtime": "^0.13.11",
"rimraf": "^3.0.2",
"rollup": "^2.53.2",
"rollup-plugin-postcss": "^4.0.0",
Expand Down
Loading

0 comments on commit cfdbd2e

Please sign in to comment.