Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: "tests"

on:
pull_request:
paths: &monitored_paths
- ".github/workflows/tests.yaml"
- "CMakeLists.txt"
- "package-lock.json"
- "package.json"
- "src/**"
- "taskfile.yaml"
- "taskfiles/**"
- "tests/**"
- "tsconfig.json"
- "vitest.config.ts"
push:
paths: *monitored_paths
schedule:
# Run daily at 00:15 UTC (the 15 is to avoid periods of high load)
- cron: "15 0 * * *"
workflow_dispatch:

permissions: {}

concurrency:
group: "${{github.workflow}}-${{github.ref}}"

# Cancel in-progress jobs for efficiency
cancel-in-progress: true

jobs:
tests:
runs-on: "ubuntu-24.04"
steps:
- uses: "actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8" # v6.0.1
with:
submodules: "recursive"

- name: "Install task"
run: "npm install -g @go-task/cli@3.48.0"

- name: "Log tool versions"
run: |-
cmake --version
md5sum --version
node --version
npm --version
task --version

- name: "Run JS tests"
run: "task tests:js"
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ dist
.idea
.vscode

# Test data
/test/data
# Tests
/tests/data
/tests/__screenshots__
185 changes: 185 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"lint:check:js": "tsc --noEmit && eslint . --max-warnings 0",
"lint:fix:js": "npm run lint:check:js -- --fix",
"release": "git diff --exit-code && task package && npm publish",
"test": "vitest run"
"test:init": "PLAYWRIGHT_BROWSERS_PATH=0 npm exec playwright -- install --with-deps",
"test": "PLAYWRIGHT_BROWSERS_PATH=0 vitest run"
Comment thread
Bill-hbrhbr marked this conversation as resolved.
Resolved
},
"type": "module",
"files": [
Expand All @@ -39,6 +40,7 @@
},
"devDependencies": {
"@types/node": "^22.19.9",
"@vitest/browser-playwright": "^4.0.18",
"eslint": "^9.39.2",
"eslint-config-yscope": "^1.1.2",
"typescript": "^5.9.3",
Expand Down
2 changes: 1 addition & 1 deletion taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3"
includes:
deps: "taskfiles/deps.yaml"
lint: "taskfiles/lint.yaml"
test: "taskfiles/test.yaml"
tests: "taskfiles/tests.yaml"
utils: "tools/yscope-dev-utils/exports/taskfiles/utils/utils.yaml"

vars:
Expand Down
6 changes: 5 additions & 1 deletion taskfiles/test.yaml → taskfiles/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ tasks:
default:
deps: ["js"]

js:
init:
deps: [":package", ":node-modules"]
cmd: "npm run test:init"
Comment thread
Bill-hbrhbr marked this conversation as resolved.
Resolved

js:
deps: ["init"]
cmd: "npm run test {{.CLI_ARGS}}"
Comment thread
Bill-hbrhbr marked this conversation as resolved.
Resolved
11 changes: 11 additions & 0 deletions tests/ClpStreamReader.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {
describe,
expect,
it,
} from "vitest";

describe("ClpStreamReader", () => {
it("dummy test", () => {
expect(true).toBe(true);
});
});
5 changes: 5 additions & 0 deletions tests/globalSetup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const globalSetup = async () => {
// no-op global setup for tests
};
Comment thread
Bill-hbrhbr marked this conversation as resolved.
Resolved

export default globalSetup;
32 changes: 29 additions & 3 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
import {defineConfig} from "vitest/config";
import {playwright} from "@vitest/browser-playwright";


export default defineConfig({
test: {
include: ["test/**/*.test.ts"],
environment: "node",
testTimeout: 30_000,
globalSetup: "tests/globalSetup.ts",
projects: [
{
test: {
name: "node",
include: ["tests/**/*.test.ts"],
environment: "node",
testTimeout: 30_000,
},
},
{
test: {
name: "browser",
include: ["tests/**/*.test.ts"],
testTimeout: 30_000,
browser: {
enabled: true,
provider: playwright(),
instances: [
{browser: "chromium"},
{browser: "firefox"},
{browser: "webkit"},
],
headless: true,
},
},
},
],
Comment thread
Bill-hbrhbr marked this conversation as resolved.
Resolved
},
});