Skip to content

Commit

Permalink
Update test setup scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
wongchito committed Jan 4, 2024
1 parent 98080a0 commit 0ff7cdc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: ./scripts/build.sh
shell: bash
env:
BUMP_VERSION: ${{ github.event.inputs.bump_version }}
BUMP_VERSION: ${{ inputs.bump_version }}

- name: Release
if: ${{ inputs.auto_deploy == 'UAT' || inputs.auto_deploy == 'PRD' }}
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@railmapgen/rmg-runtime": "^8.1.0",
"@railmapgen/rmg-translate": "^3.1.0",
"@reduxjs/toolkit": "^2.0.1",
"framer-motion": "^10.16.16",
"framer-motion": "^10.17.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-i18next": "^14.0.0",
Expand All @@ -23,15 +23,15 @@
"react-router-dom": "^6.21.1"
},
"devDependencies": {
"@testing-library/jest-dom": "^6.1.5",
"@testing-library/jest-dom": "^6.2.0",
"@testing-library/react": "^14.1.2",
"@testing-library/user-event": "^14.5.1",
"@types/node": "^20.10.5",
"@types/react": "^18.2.45",
"@testing-library/user-event": "^14.5.2",
"@types/node": "^20.10.6",
"@types/react": "^18.2.46",
"@types/react-dom": "^18.2.18",
"@types/react-router-dom": "^5.3.3",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"@typescript-eslint/eslint-plugin": "^6.17.0",
"@typescript-eslint/parser": "^6.17.0",
"@vitejs/plugin-legacy": "^5.2.0",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.56.0",
Expand All @@ -42,7 +42,7 @@
"terser": "^5.26.0",
"typescript": "^5.3.3",
"vite": "^5.0.10",
"vitest": "^1.1.0"
"vitest": "^1.1.1"
},
"scripts": {
"dev": "vite --host",
Expand Down
50 changes: 0 additions & 50 deletions src/mock-broadcast-channel.ts

This file was deleted.

16 changes: 4 additions & 12 deletions src/setupTests.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
import { createStore } from './redux';
import infoJson from '../info.json';
import { TextEncoder } from 'util';
import { vi } from 'vitest';
import { MockBroadcastChannel } from './mock-broadcast-channel';

export const createTestStore = createStore;

vi.stubGlobal('BroadcastChannel', MockBroadcastChannel);

const originalFetch = global.fetch;
global.fetch = (...args) => {
global.fetch = vi.fn().mockImplementation((...args: any[]) => {
if (args[0].toString().includes('/info.json')) {
return Promise.resolve({
ok: true,
status: 200,
json: () => Promise.resolve(infoJson),
json: () => import('../info.json').then(module => module.default),
}) as any;
} else {
return originalFetch(...args);
return originalFetch(args[0], args[1]);
}
};
});

global.TextEncoder = TextEncoder;
4 changes: 3 additions & 1 deletion src/test-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import { render, RenderOptions } from '@testing-library/react';
import { I18nextProvider } from 'react-i18next';
import i18n from './i18n/config';
import { Provider } from 'react-redux';
import { createTestStore } from './setupTests';
import { Store } from '@reduxjs/toolkit';
import { createStore } from './redux';

export const createTestStore = createStore;

interface CustomRenderOptions extends Omit<RenderOptions, 'wrapper'> {
store: Store;
Expand Down

0 comments on commit 0ff7cdc

Please sign in to comment.