From 781df93ceb08a76d8444bc072e906a9e2eb1ab4c Mon Sep 17 00:00:00 2001 From: Charles Kornoelje <33156025+charkour@users.noreply.github.com> Date: Sat, 9 Dec 2023 00:23:15 -0500 Subject: [PATCH 1/4] fix: update package.json to require react 18+ --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 34c23ba28b..d0c3f3961f 100644 --- a/package.json +++ b/package.json @@ -255,8 +255,8 @@ }, "peerDependencies": { "immer": ">=9.0", - "@types/react": ">=16.8", - "react": ">=16.8" + "@types/react": ">=18.0", + "react": ">=18.0" }, "peerDependenciesMeta": { "immer": { From 4f17d4edc5851854c0a0a34ff707368b30bfad9e Mon Sep 17 00:00:00 2001 From: Charles Kornoelje <33156025+charkour@users.noreply.github.com> Date: Sat, 9 Dec 2023 00:23:29 -0500 Subject: [PATCH 2/4] chore: update github actions to test on react 18+ --- .github/workflows/test-multiple-builds.yml | 10 +++----- .github/workflows/test-multiple-versions.yml | 26 +++++--------------- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/.github/workflows/test-multiple-builds.yml b/.github/workflows/test-multiple-builds.yml index 0ce52235c8..dfe51f45da 100644 --- a/.github/workflows/test-multiple-builds.yml +++ b/.github/workflows/test-multiple-builds.yml @@ -12,8 +12,8 @@ jobs: strategy: fail-fast: false matrix: - build: [cjs, umd] # [cjs, esm, umd, system] - env: [development, production] + build: [cjs, esm, umd] # [cjs, esm, umd, system] + env: [development] # [development, production] devtools-skip: - CI-MATRIX-NOSKIP include: @@ -39,10 +39,6 @@ jobs: - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - run: yarn install --frozen-lockfile --check-files - run: yarn build - - name: Use React 17 for production test - if: ${{ matrix.env == 'production' }} - run: | - yarn add -D react@17.0.2 react-dom@17.0.2 @testing-library/react@12.1.4 - name: Patch for DEV-ONLY if: ${{ matrix.env == 'development' }} run: | @@ -60,7 +56,7 @@ jobs: - name: Patch for ESM if: ${{ matrix.build == 'esm' }} run: | - sed -i~ "s/\/src\(.*\)\.ts/\/dist\/esm\1.js" package.json + sed -i~ "s/\/src\(.*\)\.ts/\/dist\/esm\1.js/" package.json sed -i~ "1s/^/import.meta.env=import.meta.env||{};import.meta.env.MODE='${NODE_ENV}';/" tests/*.tsx env: NODE_ENV: ${{ matrix.env }} diff --git a/.github/workflows/test-multiple-versions.yml b/.github/workflows/test-multiple-versions.yml index cc13242a97..bdf8635e3a 100644 --- a/.github/workflows/test-multiple-versions.yml +++ b/.github/workflows/test-multiple-versions.yml @@ -28,8 +28,6 @@ jobs: fail-fast: false matrix: react: - - 16.8.0 - - 17.0.0 - 18.0.0 - 18.1.0 - 18.2.0 @@ -39,18 +37,18 @@ jobs: - CI-MATRIX-NOSKIP include: - devtools-skip: CI-MATRIX-[2345] - react: 16.8.0 + react: 18.0.0 - devtools-skip: CI-MATRIX-[1345] - react: 16.8.0 + react: 18.0.0 - devtools-skip: CI-MATRIX-[1245] - react: 16.8.0 + react: 18.0.0 - devtools-skip: CI-MATRIX-[1235] - react: 16.8.0 + react: 18.0.0 - devtools-skip: CI-MATRIX-[1234] - react: 16.8.0 + react: 18.0.0 exclude: - devtools-skip: CI-MATRIX-NOSKIP - react: 16.8.0 + react: 18.0.0 steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 @@ -59,18 +57,6 @@ jobs: cache: yarn - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - run: yarn install --frozen-lockfile --check-files - - name: Install legacy testing-library - if: ${{ startsWith(matrix.react, '16.') || startsWith(matrix.react, '17.') }} - run: yarn add -D @testing-library/react@12.1.4 - - name: Patch for React 16 - if: ${{ startsWith(matrix.react, '16.') }} - run: | - sed -i~ '1s/^/import React from "react";/' tests/*.tsx - sed -i~ 's/"jsx": "react-jsx"/"jsx": "react"/' tsconfig.json - sed -i~ 's/import\.meta\.env[?]\.MODE/"DEVELOPMENT".toLowerCase()/' src/*.ts src/*/*.ts - sed -i~ "s/it('\[${DEVTOOLS_SKIP}\]/it.skip('/" tests/devtools.test.tsx - env: - DEVTOOLS_SKIP: ${{ matrix.devtools-skip }} - name: Test ${{ matrix.react }} ${{ matrix.devtools-skip }} run: | yarn add -D react@${{ matrix.react }} react-dom@${{ matrix.react }} From 394b7a63123555671b542ae4b1a91324c798772c Mon Sep 17 00:00:00 2001 From: Charles Kornoelje <33156025+charkour@users.noreply.github.com> Date: Sat, 16 Dec 2023 20:12:48 -0800 Subject: [PATCH 3/4] chore: remove devtools-skip hack from actions --- .github/workflows/test-multiple-builds.yml | 22 -------------------- .github/workflows/test-multiple-versions.yml | 18 +--------------- 2 files changed, 1 insertion(+), 39 deletions(-) diff --git a/.github/workflows/test-multiple-builds.yml b/.github/workflows/test-multiple-builds.yml index dfe51f45da..5baca7d278 100644 --- a/.github/workflows/test-multiple-builds.yml +++ b/.github/workflows/test-multiple-builds.yml @@ -14,22 +14,6 @@ jobs: matrix: build: [cjs, esm, umd] # [cjs, esm, umd, system] env: [development] # [development, production] - devtools-skip: - - CI-MATRIX-NOSKIP - include: - - devtools-skip: CI-MATRIX-[2345] - build: umd - - devtools-skip: CI-MATRIX-[1345] - build: umd - - devtools-skip: CI-MATRIX-[1245] - build: umd - - devtools-skip: CI-MATRIX-[1235] - build: umd - - devtools-skip: CI-MATRIX-[1234] - build: umd - exclude: - - devtools-skip: CI-MATRIX-NOSKIP - build: umd steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 @@ -64,16 +48,10 @@ jobs: if: ${{ matrix.build == 'umd' && matrix.env == 'development' }} run: | sed -i~ "s/\/src\(.*\)\.ts/\/dist\/umd\1.development.js/" package.json - sed -i~ "s/it('\[${DEVTOOLS_SKIP}\]/it.skip('/" tests/devtools.test.tsx - env: - DEVTOOLS_SKIP: ${{ matrix.devtools-skip }} - name: Patch for UMD (PRD) if: ${{ matrix.build == 'umd' && matrix.env == 'production' }} run: | sed -i~ "s/\/src\(.*\)\.ts/\/dist\/umd\1.production.js/" package.json - sed -i~ "s/it('\[${DEVTOOLS_SKIP}\]/it.skip('/" tests/devtools.test.tsx - env: - DEVTOOLS_SKIP: ${{ matrix.devtools-skip }} - name: Patch for SystemJS if: ${{ matrix.build == 'system' }} run: | diff --git a/.github/workflows/test-multiple-versions.yml b/.github/workflows/test-multiple-versions.yml index bdf8635e3a..1b3ffab78c 100644 --- a/.github/workflows/test-multiple-versions.yml +++ b/.github/workflows/test-multiple-versions.yml @@ -33,22 +33,6 @@ jobs: - 18.2.0 - 18.3.0-canary-6c7b41da3-20231123 - 0.0.0-experimental-6c7b41da3-20231123 - devtools-skip: - - CI-MATRIX-NOSKIP - include: - - devtools-skip: CI-MATRIX-[2345] - react: 18.0.0 - - devtools-skip: CI-MATRIX-[1345] - react: 18.0.0 - - devtools-skip: CI-MATRIX-[1245] - react: 18.0.0 - - devtools-skip: CI-MATRIX-[1235] - react: 18.0.0 - - devtools-skip: CI-MATRIX-[1234] - react: 18.0.0 - exclude: - - devtools-skip: CI-MATRIX-NOSKIP - react: 18.0.0 steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 @@ -57,7 +41,7 @@ jobs: cache: yarn - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - run: yarn install --frozen-lockfile --check-files - - name: Test ${{ matrix.react }} ${{ matrix.devtools-skip }} + - name: Test ${{ matrix.react }} run: | yarn add -D react@${{ matrix.react }} react-dom@${{ matrix.react }} yarn test:ci From b4742b76e857c2b84ca57831dd4e42c0e422292e Mon Sep 17 00:00:00 2001 From: Charles Kornoelje <33156025+charkour@users.noreply.github.com> Date: Sat, 16 Dec 2023 20:22:10 -0800 Subject: [PATCH 4/4] chore(test): remove CI-SKIP from devtools tests --- tests/devtools.test.tsx | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/tests/devtools.test.tsx b/tests/devtools.test.tsx index 71d4f9cc88..ba4645c05b 100644 --- a/tests/devtools.test.tsx +++ b/tests/devtools.test.tsx @@ -678,7 +678,7 @@ it('preserves isRecording after setting from devtools', async () => { /* features: * [] if name is undefined - use multiple devtools connections. * [] if name and store is defined - use connection for specific 'name'. - * [] if two stores are coonected to one 'name' group and. + * [] if two stores are connected to one 'name' group and. * another connected to another 'name' group, then feature should work * [] check actions with this feature, for multiple stores that store prefixes are added - * [] - reset @@ -720,9 +720,7 @@ describe('when redux connection was called on multiple stores with `name` undefi }) describe('when `store` property was provided in `devtools` call in options', () => { - // FIXME: Run this test separately in CI, until we're able to test modules in isolation i.e. use jest.resetModule and re-import modules in each test - // Relevant issues https://github.com/nodejs/node/issues/35889 - it('[CI-MATRIX-1] should create single connection for all indernal calls of .connect and `store` is not passed to .connect', async () => { + it('should create single connection for all internal calls of .connect and `store` is not passed to .connect', async () => { const { devtools: newDevtools } = await import('zustand/middleware') const options1 = { store: 'store1123', foo: 'bar1' } @@ -743,9 +741,7 @@ describe('when redux connection was called on multiple stores with `name` undefi }) }) - // FIXME: Run this test separately in CI, until we're able to test modules in isolation i.e. use jest.resetModule and re-import modules in each test - // Relevant issues https://github.com/nodejs/node/issues/35889 - it('[CI-MATRIX-2] should call `.init` on single connection with combined states after each `create(devtools` call', async () => { + it('should call `.init` on single connection with combined states after each `create(devtools` call', async () => { const { devtools: newDevtools } = await import('zustand/middleware') const options1 = { store: 'store12' } @@ -839,9 +835,7 @@ describe('when redux connection was called on multiple stores with `name` provid }) }) - // FIXME: Run this test separately in CI, until we're able to test modules in isolation i.e. use jest.resetModule and re-import modules in each test - // Relevant issues https://github.com/nodejs/node/issues/35889 - it('[CI-MATRIX-3] should call `.init` on single connection with combined states after each `create(devtools` call', async () => { + it('should call `.init` on single connection with combined states after each `create(devtools` call', async () => { const { devtools: newDevtools } = await import('zustand/middleware') const connectionNameGroup1 = 'test1' const connectionNameGroup2 = 'test2' @@ -2352,9 +2346,7 @@ describe('when create devtools was called multiple times with `name` and `store` console.error = originalConsoleError }) - // FIXME: Run this test separately in CI, until we're able to test modules in isolation i.e. use jest.resetModule and re-import modules in each test - // Relevant issues https://github.com/nodejs/node/issues/35889 - it('[CI-MATRIX-4] does nothing even if there is `api.dispatch`, connections isolated from each other', async () => { + it('does nothing even if there is `api.dispatch`, connections isolated from each other', async () => { const { devtools: newDevtools } = await import('zustand/middleware') const name1 = 'name1' @@ -2402,9 +2394,7 @@ describe('when create devtools was called multiple times with `name` and `store` expect((api2 as any).dispatch).not.toBeCalled() }) - // FIXME: Run this test separately in CI, until we're able to test modules in isolation i.e. use jest.resetModule and re-import modules in each test - // Relevant issues https://github.com/nodejs/node/issues/35889 - it('[CI-MATRIX-5] dispatches with `api.dispatch` when `api.dispatchFromDevtools` is set to true, connections are isolated from each other', async () => { + it('dispatches with `api.dispatch` when `api.dispatchFromDevtools` is set to true, connections are isolated from each other', async () => { const { devtools: newDevtools } = await import('zustand/middleware') const name1 = 'name1' const name2 = 'name2'