Skip to content

Commit 37a0483

Browse files
authored
Upload Jest and Vite unit test reuslts to Test Analysis Bot (#7794)
1 parent 8367298 commit 37a0483

File tree

5 files changed

+70
-4
lines changed

5 files changed

+70
-4
lines changed

.github/workflows/unit-tests.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ jobs:
6464
env:
6565
VITE_KITTYCAD_API_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
6666

67+
- name: Upload results
68+
if: always()
69+
run: .github/ci-cd-scripts/upload-results.sh
70+
env:
71+
TAB_API_URL: ${{ secrets.TAB_API_URL }}
72+
TAB_API_KEY: ${{ secrets.TAB_API_KEY }}
73+
CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
74+
CI_PR_NUMBER: ${{ github.event.pull_request.number }}
75+
CI_SUITE: unit
76+
6777
- name: Check for changes
6878
if: ${{ github.event_name != 'release' && github.event_name != 'schedule' }}
6979
id: git-check
@@ -122,3 +132,13 @@ jobs:
122132
123133
- name: Run component tests
124134
run: npm run test:unit:components
135+
136+
- name: Upload results
137+
if: always()
138+
run: .github/ci-cd-scripts/upload-results.sh
139+
env:
140+
TAB_API_URL: ${{ secrets.TAB_API_URL }}
141+
TAB_API_KEY: ${{ secrets.TAB_API_KEY }}
142+
CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
143+
CI_PR_NUMBER: ${{ github.event.pull_request.number }}
144+
CI_SUITE: unit:components

jest-component-unit-tests/jest.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ const jestConfig: Config = {
2020
// TAG: paths, path, baseUrl, alias
2121
// This is necessary to use tsconfig path aliases.
2222
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/../' }),
23+
reporters: [
24+
"default",
25+
["jest-junit", {
26+
outputDirectory: "test-results",
27+
outputName: "junit.xml"
28+
}]
29+
],
2330
}
2431

2532
export default jestConfig

package-lock.json

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@
110110
"remove-importmeta": "sed -i 's/import.meta.url/window.location.origin/g' \"./rust/kcl-wasm-lib/pkg/kcl_wasm_lib.js\"; sed -i '' 's/import.meta.url/window.location.origin/g' \"./rust/kcl-wasm-lib/pkg/kcl_wasm_lib.js\" || echo \"sed for both mac and linux\"",
111111
"lint-fix": "eslint --fix --ext .ts --ext .tsx src e2e packages/codemirror-lsp-client/src rust/kcl-language-server/client/src",
112112
"lint": "eslint --max-warnings 0 --ext .ts --ext .tsx src e2e packages/codemirror-lsp-client/src rust/kcl-language-server/client/src",
113-
"url-checker":"./scripts/url-checker.sh",
114-
"url-checker:overwrite":"npm run url-checker > scripts/known/urls.txt",
115-
"url-checker:diff":"./scripts/diff-url-checker.sh",
113+
"url-checker": "./scripts/url-checker.sh",
114+
"url-checker:overwrite": "npm run url-checker > scripts/known/urls.txt",
115+
"url-checker:diff": "./scripts/diff-url-checker.sh",
116116
"circular-deps": "dpdm --no-warning --no-tree -T --skip-dynamic-imports=circular src/index.tsx",
117117
"circular-deps:overwrite": "npm run circular-deps | sed '$d' | grep -v '^npm run' > scripts/known/circular.txt",
118118
"circular-deps:diff": "./scripts/diff-circular-deps.sh",
@@ -135,7 +135,7 @@
135135
"test:rust": "(cd rust && just test && just lint)",
136136
"test:snapshots": "cross-env TARGET=web NODE_ENV=development playwright test --config=playwright.config.ts --grep=@snapshot --trace=on",
137137
"test:unit": "vitest run --mode=development --exclude **/jest-component-unit-tests/*",
138-
"test:unit:components": "jest -c jest-component-unit-tests/jest.config.ts --rootDir jest-component-unit-tests/",
138+
"test:unit:components": "jest --config=jest-component-unit-tests/jest.config.ts --rootDir=jest-component-unit-tests/",
139139
"test:e2e:web": "cross-env TARGET=web NODE_ENV=development playwright test --config=playwright.config.ts --project=\"Google Chrome\" --grep=@web",
140140
"test:e2e:desktop": "cross-env TARGET=desktop playwright test --config=playwright.electron.config.ts --grep-invert=\"@snapshot|@web\"",
141141
"test:e2e:desktop:local": "cross-env TARGET=desktop npm run tronb:vite:dev && playwright test --config=playwright.electron.config.ts --grep-invert=\"@snapshot|@web\" --grep-invert=\"$(curl --silent https://test-analysis-bot.hawk-dinosaur.ts.net/projects/KittyCAD/modeling-app/tests/disabled/regex)\"",
@@ -213,6 +213,7 @@
213213
"jest": "^29.7.0",
214214
"jest-environment-jsdom": "^29.7.0",
215215
"jest-fixed-jsdom": "^0.0.9",
216+
"jest-junit": "^16.0.0",
216217
"kill-port": "^2.0.1",
217218
"msw": "^2.7.6",
218219
"node-fetch": "^3.3.2",

vitest.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,9 @@ export default defineConfig({
1818
deps: {
1919
external: [/playwright/],
2020
},
21+
reporters: ['default', 'junit'],
22+
outputFile: {
23+
junit: 'test-results/junit.xml',
24+
},
2125
},
2226
})

0 commit comments

Comments
 (0)