Skip to content

Commit a78c497

Browse files
committed
Add tests for utility to bypass unreliable tests
1 parent 58dc338 commit a78c497

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

.github/workflows/static-analysis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,13 @@ jobs:
141141
if: ${{ github.event_name != 'release' && github.event_name != 'schedule' }}
142142
run: yarn playwright install chromium --with-deps
143143

144-
- name: run unit tests
144+
- name: Run unit tests
145145
if: ${{ github.event_name != 'release' && github.event_name != 'schedule' }}
146146
run: xvfb-run -a yarn test:unit
147147
env:
148148
VITE_KC_DEV_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
149149

150-
- name: check for changes
150+
- name: Check for changes
151151
if: ${{ github.event_name != 'release' && github.event_name != 'schedule' }}
152152
id: git-check
153153
run: |

e2e/playwright/test-utils.test.ts

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { orRunWhenFullSuiteEnabled } from './test-utils'
2+
3+
const originalEnv = { ...process.env }
4+
5+
afterAll(() => {
6+
process.env = { ...originalEnv }
7+
})
8+
9+
describe('utility to bypass unreliable tests', () => {
10+
it('always runs them on dedicated branch', () => {
11+
process.env.GITHUB_EVENT_NAME = 'push'
12+
process.env.GITHUB_REF = 'refs/heads/all-e2e'
13+
process.env.GITHUB_HEAD_REF = ''
14+
process.env.GITHUB_BASE_REF = ''
15+
const condition = orRunWhenFullSuiteEnabled()
16+
expect(condition).toBe(false)
17+
})
18+
it('skips them on the main branch', () => {
19+
process.env.GITHUB_EVENT_NAME = 'push'
20+
process.env.GITHUB_REF = 'refs/heads/main'
21+
process.env.GITHUB_HEAD_REF = ''
22+
process.env.GITHUB_BASE_REF = ''
23+
const condition = orRunWhenFullSuiteEnabled()
24+
expect(condition).toBe(true)
25+
})
26+
it('skips them on pull requests', () => {
27+
process.env.GITHUB_EVENT_NAME = 'pull_request'
28+
process.env.GITHUB_REF = 'refs/pull/5883/merge'
29+
process.env.GITHUB_HEAD_REF = 'my-branch'
30+
process.env.GITHUB_BASE_REF = 'main'
31+
const condition = orRunWhenFullSuiteEnabled()
32+
expect(condition).toBe(true)
33+
})
34+
})

vite.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const config = defineConfig({
3535
coverage: {
3636
provider: 'istanbul', // or 'v8'
3737
},
38-
exclude: [...configDefaults.exclude, '**/e2e/**/*', 'rust'],
38+
exclude: [...configDefaults.exclude, '**/e2e/**/*.spec.*', 'rust'],
3939
deps: {
4040
optimizer: {
4141
web: {

0 commit comments

Comments
 (0)