-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds the test actions to run on pull requests and pushes to the main branch. fixes #260
- Loading branch information
Showing
5 changed files
with
94 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,43 @@ | ||
name: 'Pull Request' | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
# Required to checkout the code | ||
contents: read | ||
# Required to put a comment into the pull-request | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.x' | ||
|
||
- name: Cache Node.js modules | ||
id: cache-node-modules | ||
uses: actions/cache@v4 | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node-modules- | ||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: 'Test' | ||
run: npx vitest --coverage.enabled true | ||
|
||
- name: 'Report Coverage' | ||
# Set if: always() to also generate the report if tests are failing | ||
# Only works if you set `reportOnFailure: true` in your vite config as specified above | ||
if: always() | ||
uses: davelosert/vitest-coverage-report-action@v2 |
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,10 +1,5 @@ | ||
{ | ||
"extends": "astro/tsconfigs/strict", | ||
"include": [".astro/types.d.ts", "**/*"], | ||
"exclude": ["dist"], | ||
"compilerOptions": { | ||
"jsx": "react-jsx", | ||
"jsxImportSource": "react", | ||
"types": ["vitest/globals", "@testing-library/jest-dom"] | ||
} | ||
"exclude": ["dist"] | ||
} |
This file contains 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 |
---|---|---|
@@ -1,9 +1,20 @@ | ||
import { defineConfig } from 'vite'; | ||
/// <reference types="vitest/config" /> | ||
import { defineConfig } from 'astro/config'; | ||
import { config } from './astro.config.mjs'; | ||
|
||
export default defineConfig({ | ||
...config, | ||
// @ts-expect-error - this is a vitest config | ||
test: { | ||
globals: true, | ||
environment: 'jsdom', | ||
setupFiles: './vitest.setup.ts', | ||
coverage: { | ||
// you can include other reporters, but 'json-summary' is required, json is recommended | ||
reporter: ['text', 'json-summary', 'json'], | ||
// If you want a coverage reports even if your tests are failing, include the reportOnFailure option | ||
reportOnFailure: true, | ||
}, | ||
typecheck: true, | ||
}, | ||
}); |