-
Notifications
You must be signed in to change notification settings - Fork 17
ci: Add unit testing infra: #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
a2f4075
Add Jest configuration and tests.
junhaoliao ba1bb9e
Add GitHub Actions workflow for automated testing.
junhaoliao 1a22afe
Non-zero result: Failed test.
junhaoliao 11825a1
Non-zero result: Failed coverage.
junhaoliao a82b2f6
Revert "Non-zero result: Failed coverage."
junhaoliao d313cf4
Revert "Non-zero result: Failed test."
junhaoliao 571100c
Debug github annotations.
junhaoliao 859d317
Fix test case.
junhaoliao 492ba0f
Log primary reporter.
junhaoliao ea1d7fd
Update test description.
junhaoliao 3afa8dc
Remove `actions: "write"` from permissions list.
junhaoliao fe366ab
Add line before comment.
junhaoliao d1f6b68
Update daily run comment.
junhaoliao 1fb3211
Merge remote-tracking branch 'yscope/main' into jest
junhaoliao cb9325a
Update dependencies in package-lock.json.
junhaoliao 36677d4
Docs - Apply suggestions from code review
junhaoliao bffe451
Check env var GITHUB_ACTIONS instead of CI - Apply suggestions from c…
junhaoliao 2a95501
Add period to reporter log statement and wrap the JSON strigified PRI…
junhaoliao 9f27111
Remove coverage threshold overrides for individual components.
junhaoliao 475740d
Enforce 100% branches coverage.
junhaoliao b11ac40
Remove `testEnvironment: "node"` which is the default.
junhaoliao 7256bdb
Add jest.config.ts to npm script `lint:check:js`.
junhaoliao d701e07
Update docs for `workerThreads` jest config option - Apply suggestion…
junhaoliao e4f90d4
Run eslint with `.` and add `ignorePatterns` in ESLint config.
junhaoliao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: "test" | ||
|
||
on: | ||
pull_request: | ||
types: ["opened", "reopened", "synchronize"] | ||
push: | ||
schedule: | ||
# Run at midnight UTC every day with 15 minutes delay added to avoid high load periods | ||
- cron: "15 0 * * *" | ||
workflow_dispatch: | ||
|
||
permissions: {} | ||
|
||
concurrency: | ||
group: "${{github.workflow}}-${{github.ref}}" | ||
|
||
# Cancel in-progress jobs for efficiency | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
test: | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- uses: "actions/checkout@v4" | ||
with: | ||
submodules: "recursive" | ||
- uses: "actions/setup-node@v4" | ||
with: | ||
node-version: "22" | ||
cache: "npm" | ||
cache-dependency-path: "./package-lock.json" | ||
- run: "npm clean-install" | ||
- run: "npm run test" | ||
Henry8192 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import type {Config} from "jest"; | ||
import os from "node:os"; | ||
import pathPosix from "node:path/posix"; | ||
|
||
|
||
let PRIMARY_REPORTER: string | [string, Record<string, unknown>] = "default"; | ||
if ("undefined" !== typeof process.env.CI) { | ||
junhaoliao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
PRIMARY_REPORTER = [ | ||
"github-actions", | ||
{silent: false}, | ||
]; | ||
kirkrodrigues marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
console.log(`Environment variable "CI"="${process.env.CI}": ` + | ||
junhaoliao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`primary reporter will be ${JSON.stringify(PRIMARY_REPORTER)}`); | ||
|
||
const JEST_CONFIG: Config = { | ||
collectCoverage: true, | ||
collectCoverageFrom: ["src/**/*.{ts,tsx}"], | ||
coverageProvider: "v8", | ||
coverageReporters: ["text"], | ||
coverageThreshold: { | ||
"global": { | ||
functions: 90, | ||
lines: 90, | ||
}, | ||
kirkrodrigues marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// eslint-disable-next-line no-warning-comments | ||
// TODO: Remove / Adjust below overrides as more test cases are added. | ||
junhaoliao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"src/*.tsx": { | ||
functions: 0, | ||
lines: 0, | ||
}, | ||
"src/components/": { | ||
functions: 0, | ||
lines: 0, | ||
}, | ||
"src/contexts/": { | ||
functions: 0, | ||
lines: 0, | ||
}, | ||
"src/services/": { | ||
functions: 0, | ||
lines: 0, | ||
}, | ||
"src/typings/": { | ||
functions: 0, | ||
lines: 0, | ||
}, | ||
"src/utils/": { | ||
functions: 0, | ||
lines: 0, | ||
}, | ||
"src/utils/math.ts": { | ||
functions: 100, | ||
lines: 100, | ||
}, | ||
}, | ||
displayName: { | ||
name: "yscope-log-viewer", | ||
color: "blue", | ||
}, | ||
errorOnDeprecated: true, | ||
maxConcurrency: os.cpus().length, | ||
maxWorkers: "100%", | ||
openHandlesTimeout: 1000, | ||
reporters: [ | ||
PRIMARY_REPORTER, | ||
"summary", | ||
], | ||
showSeed: true, | ||
testEnvironment: "node", | ||
kirkrodrigues marked this conversation as resolved.
Show resolved
Hide resolved
|
||
testMatch: [ | ||
pathPosix.join(__dirname, "test/**/?(*)test.{ts,tsx}"), | ||
], | ||
testTimeout: 5000, | ||
transform: { | ||
".(ts|tsx)$": [ | ||
"ts-jest", | ||
{useESM: true}, | ||
kirkrodrigues marked this conversation as resolved.
Show resolved
Hide resolved
|
||
], | ||
}, | ||
verbose: true, | ||
|
||
// Caution: Extra properties set on `Error`, `Map` or `Set` will not be passed on through the | ||
// serialization. | ||
junhaoliao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
workerThreads: true, | ||
}; | ||
|
||
export default JEST_CONFIG; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.