Skip to content

Commit

Permalink
Add vitest (test runner) test CI job, and a very basic test (#21)
Browse files Browse the repository at this point in the history
* Add jest (test runner) and a single always-passing test

* Add testing to GH Actions workflow

* Combine lint and test in one job

* Change from jest to vitest; add a working test

* More mocking - not sure why it passes locally and fails in CI

* More mocking - not sure why it passes locally and fails in CI

* More mocking - not sure why it passes locally and fails in CI

* Use playwright for headless browser testing

* Switch from v8 to istanbul for coverage in browser mode

* Only install chromium in CI for now
  • Loading branch information
aganders3 authored Feb 21, 2024
1 parent 70bb3d9 commit 8c5f8aa
Show file tree
Hide file tree
Showing 8 changed files with 2,465 additions and 737 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ module.exports = {
},
settings: {
"import/resolver": {
typescript: {}
typescript: {},
},
"react": {
"version": "detect"
version: "detect",
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:

jobs:
lint:
lint-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -14,3 +14,5 @@ jobs:
node-version: 21
- run: npm ci
- run: npm run lint
- run: npx playwright install chromium
- run: npm run coverage
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Install with `npm install`

Run the dev server with `npm run dev`

See [scene.tsx](https://github.com/aganders3/points-web-viewer/blob/a66ff6aa7ff3cdf1259cf4090ac388ac59d85991/src/scene.tsx) for an example component displaying a three.js scene.
Run tests with `npm run test` or `npm run coverage`
14 changes: 14 additions & 0 deletions __tests__/main.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { expect, test } from "vitest";

import Scene from "../src/scene";
import React from "react";
import { render } from "@testing-library/react";

test("tests work", () => {
expect(true).toBeTruthy();
});

test("render Scene", () => {
const { container } = render(<Scene renderWidth={800} />);
expect(container).not.toBeNull();
});
Loading

0 comments on commit 8c5f8aa

Please sign in to comment.