Skip to content

Commit

Permalink
Add tests (#161)
Browse files Browse the repository at this point in the history
* add tests

* chore: reformat snapshots

* chore: reformat snapshots

* chore: add a test case to ensure blackbox tests consistency with zxing-cpp test runners

* fix: tsconfigs

* chore: add test jobs

* fix: checkout submodules

* fix: specify base directory to scan for test files

* fix: add exclude patterns for tests

* fix: use exclude cli option
  • Loading branch information
Sec-ant authored Oct 16, 2024
1 parent 925e12f commit df00118
Show file tree
Hide file tree
Showing 6,548 changed files with 204,842 additions and 48 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__snapshots__/** linguist-vendored
13 changes: 13 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Test
description: Run tests

runs:
using: composite
steps:
- name: Build WASM
shell: bash
run: pnpm -s cmake && pnpm -s build:wasm

- name: Run Tests
shell: bash
run: pnpm -s test -- --exclude ".*/**/*"
2 changes: 2 additions & 0 deletions .github/workflows/preview-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
submodules: true

- name: Setup
uses: ./.github/actions/setup
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
submodules: true

- name: Setup
uses: ./.github/actions/setup

- name: Test
uses: ./.github/actions/test

- name: Get Next Package Version
id: package-version
run: echo "version=$(pnpm -s changeset status --output=release.json && jq -r '.releases[0].newVersion // '$(npm pkg get version)'' release.json && rm release.json)" >> $GITHUB_OUTPUT
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Test

on: [pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
submodules: true

- name: Setup
uses: ./.github/actions/setup

- name: Test
uses: ./.github/actions/test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ src/**/zxing_*.js
.emsdk-cache
*.tgz
*.tar.gz
*.tsbuildinfo
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"files": {
"ignoreUnknown": true,
"ignore": ["zxing-cpp"]
"ignore": ["zxing-cpp", "__snapshots__"]
},
"formatter": {
"indentStyle": "space"
Expand Down
22 changes: 14 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
},
"scripts": {
"update-hooks": "simple-git-hooks",
"changeset": "changeset",
"submodule:init": "git submodule update --init",
"submodule:update": "git submodule update --remote",
"cmake": "emcmake cmake -S src/cpp -B build",
Expand All @@ -72,7 +71,7 @@
"docs:preview": "vite preview --outDir ./docs",
"dev": "vite",
"lint": "biome lint .",
"type-check": "tsc --noEmit --emitDeclarationOnly false",
"type-check": "tsc -p ./tsconfig.pkg.json --noEmit --emitDeclarationOnly false",
"format:prettier": "pretty-quick",
"format:biome": "biome format . --write",
"format": "pnpm -s format:prettier && pnpm -s format:biome",
Expand All @@ -84,15 +83,17 @@
"build:cjs": "tsx ./scripts/build-cjs.ts",
"build:iife": "tsx ./scripts/build-iife.ts",
"build": "conc \"pnpm:build:es\" \"pnpm:build:cjs\" \"pnpm:build:iife\"",
"postbuild:es": "tsc --declarationDir ./dist/es",
"postbuild:cjs": "tsc --declarationDir ./dist/cjs",
"postbuild:es": "tsc -p ./tsconfig.pkg.json --declarationDir ./dist/es",
"postbuild:cjs": "tsc -p ./tsconfig.pkg.json --declarationDir ./dist/cjs",
"postbuild": "conc \"pnpm:copy:wasm\" \"pnpm:docs:build\"",
"build:all": "pnpm -s submodule:init && pnpm -s cmake && pnpm -s build:wasm && pnpm -s build",
"preview": "vite preview",
"prepublishOnly": "pnpm -s build:all",
"bump-biome:latest": "pnpm add -DE @biomejs/biome@latest",
"bump-biome:nightly": "pnpm add -DE @biomejs/biome@nightly",
"sync-emsdk": "./scripts/sync-emsdk.sh"
"sync-emsdk": "./scripts/sync-emsdk.sh",
"test": "vitest --hideSkippedTests",
"test:ui": "vitest --hideSkippedTests --ui"
},
"devDependencies": {
"@babel/core": "^7.25.8",
Expand All @@ -101,18 +102,23 @@
"@changesets/cli": "^2.27.9",
"@types/babel__core": "^7.20.5",
"@types/node": "^22.7.5",
"@vitest/ui": "^2.1.3",
"concurrently": "^9.0.1",
"copy-files-from-to": "^3.11.0",
"jimp": "^1.6.0",
"lint-staged": "^15.2.10",
"nano-memoize": "^3.0.16",
"prettier": "^3.3.3",
"pretty-quick": "^4.0.0",
"rimraf": "^6.0.1",
"simple-git-hooks": "^2.11.1",
"tinyglobby": "^0.2.9",
"tsx": "^4.19.1",
"typedoc": "^0.26.9",
"typedoc": "^0.26.10",
"typescript": "^5.6.3",
"vite": "^5.4.8",
"vite-plugin-babel": "^1.2.0"
"vite": "^5.4.9",
"vite-plugin-babel": "^1.2.0",
"vitest": "^2.1.3"
},
"dependencies": {
"@types/emscripten": "^1.39.13"
Expand Down
Loading

0 comments on commit df00118

Please sign in to comment.