diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0c052e1..1423d59 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -26,8 +26,10 @@ jobs: run: npm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }} - uses: actions/setup-node@v2 with: - node-version: '16.x' + node-version: '22.x' registry-url: 'https://registry.npmjs.org' + - name: Force NPM clean + run: npm cache clean --force - name: Install Modules run: npm install - name: Run type check diff --git a/package.json b/package.json index 9956da5..744a88e 100644 --- a/package.json +++ b/package.json @@ -48,25 +48,27 @@ "@testing-library/jest-dom": "^5.13.0", "@testing-library/react": "^16.3.0", "@types/jest": "^27.0.3", + "@types/node": "^18.17.0", "@types/offscreencanvas": "^2019.6.4", "@types/react": "^18.0.0", "@types/testing-library__jest-dom": "^5.9.5", - "@typescript-eslint/eslint-plugin": "^5.7.0", - "@typescript-eslint/parser": "^5.7.0", + "@typescript-eslint/eslint-plugin": "^6.21.0", + "@typescript-eslint/parser": "^6.21.0", "auto-changelog": "^2.3.0", "babel-loader": "^8.2.5", "bunchee": "1.8.5", - "eslint": "^7.28.0", + "eslint": "^8.57.1", "eslint-config-prettier": "^8.3.0", - "eslint-config-standard": "^16.0.3", + "eslint-config-standard": "^17.1.0", "eslint-plugin-import": "^2.23.4", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^3.4.0", - "eslint-plugin-promise": "^5.1.0", + "eslint-plugin-promise": "^6.6.0", "eslint-plugin-react": "^7.27.1", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-storybook": "^0.5.12", "jest": "^27.0.4", + "jest-mock": "^30.0.5", "prettier": "^2.3.1", "react": "^18.0.0", "react-dom": "^18.0.0", diff --git a/test/useStateMachine.test.tsx b/test/useStateMachine.test.tsx index 74c9398..37fd7bd 100644 --- a/test/useStateMachine.test.tsx +++ b/test/useStateMachine.test.tsx @@ -1,4 +1,3 @@ -import { mocked } from 'jest-mock'; import { renderHook } from '@testing-library/react'; import useStateMachineInput from '../src/hooks/useStateMachineInput'; @@ -35,6 +34,7 @@ function getRiveMock({ const riveMock = new Rive({ canvas: undefined as unknown as HTMLCanvasElement, }); + if (smiInputs) { riveMock.stateMachineInputs = jest.fn().mockReturnValue(smiInputs); } @@ -51,8 +51,6 @@ describe('useStateMachineInput', () => { it('returns null if there is no state machine name', () => { const riveMock = getRiveMock(); - mocked(Rive).mockImplementation(() => riveMock); - const { result } = renderHook(() => useStateMachineInput(riveMock, '', 'testInput') ); @@ -71,10 +69,8 @@ describe('useStateMachineInput', () => { it('returns null if there are no inputs for the state machine', () => { const riveMock = getRiveMock({ smiInputs: [] }); - mocked(Rive).mockImplementation(() => riveMock); - const { result } = renderHook(() => - useStateMachineInput(riveMock as Rive, 'smName', '') + useStateMachineInput(riveMock, 'smName', '') ); expect(result.current).toBeNull(); }); @@ -85,8 +81,6 @@ describe('useStateMachineInput', () => { } as StateMachineInput; const riveMock = getRiveMock({ smiInputs: [smInput] }); - mocked(Rive).mockImplementation(() => riveMock); - const { result } = renderHook(() => useStateMachineInput(riveMock, 'smName', 'numInput') ); @@ -99,8 +93,6 @@ describe('useStateMachineInput', () => { } as StateMachineInput; const riveMock = getRiveMock({ smiInputs: [smInput] }); - mocked(Rive).mockImplementation(() => riveMock); - const { result } = renderHook(() => useStateMachineInput(riveMock, 'smName', 'boolInput') ); @@ -113,7 +105,6 @@ describe('useStateMachineInput', () => { value: false, } as StateMachineInput; const riveMock = getRiveMock({ smiInputs: [smInput] }); - mocked(Rive).mockImplementation(() => riveMock); const { result } = renderHook(() => useStateMachineInput(riveMock, 'smName', 'boolInput', true)