Skip to content

Commit

Permalink
Fix CI tests
Browse files Browse the repository at this point in the history
- It seems like the new version of Vite much like Node.js allows packages to self-reference themselves, which became a problem considering how we were running the tests against the build artifact during CI.
  • Loading branch information
aryaemami59 committed Jun 24, 2024
1 parent af3b7b6 commit e373dc3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: [master]
on: [push, pull_request, workflow_dispatch]

jobs:
build:
Expand Down Expand Up @@ -76,9 +72,12 @@ jobs:
- name: Install build artifact
run: yarn add ./package.tgz

- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./vitest.config.mts
- name: Erase path aliases
run: sed -i -e /@remap-prod-remove-line/d tsconfig.base.json

- name: Run tests, against dist
env:
TEST_DIST: true
run: yarn test

test-types:
Expand Down Expand Up @@ -108,7 +107,12 @@ jobs:
- name: Install TypeScript ${{ matrix.ts }}
run: yarn add typescript@${{ matrix.ts }}

- name: Erase path aliases
run: sed -i -e /@remap-prod-remove-line/d tsconfig.base.json

- name: Test types
env:
TEST_DIST: true
run: |
yarn tsc --version
yarn type-tests
Expand Down
5 changes: 4 additions & 1 deletion vitest.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ export default defineConfig({
test: {
globals: true,
alias: {
'redux-thunk': new URL('src/index.ts', import.meta.url).pathname, // @remap-prod-remove-line
'redux-thunk': new URL(
process.env.TEST_DIST ? 'node_modules/redux-thunk' : 'src/index.ts',
import.meta.url
).pathname,

// this mapping is disabled as we want `dist` imports in the tests only to be used for "type-only" imports which don't play a role for jest
'@internal': new URL('src', import.meta.url).pathname
Expand Down

0 comments on commit e373dc3

Please sign in to comment.