Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests against dist folder #4487

Merged
merged 4 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
name: Check for changes
runs-on: ubuntu-latest
outputs:
toolkit: ${{ steps.filter.outputs.toolkit }}
src: ${{ steps.filter.outputs.src }}
steps:
- uses: actions/checkout@v2
- uses: dorny/paths-filter@v2
Expand All @@ -15,10 +15,11 @@ jobs:
filters: |
src:
- 'src/**'
- 'test/**'

build:
needs: changes
#if: ${{ needs.changes.outputs.src == 'true' }}
if: ${{ needs.changes.outputs.src == 'true' }}

name: Lint, Test, Build & Pack on Node ${{ matrix.node }}

Expand All @@ -40,6 +41,9 @@ jobs:
- name: Install deps
run: yarn install

- name: Build
run: yarn build

- name: Pack
run: yarn pack

Expand Down Expand Up @@ -79,6 +83,8 @@ jobs:
- name: Install build artifact
run: yarn add ./package.tgz

- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.json ./vitest.config.ts ./test/tsconfig.json ./test/typescript/tsconfig.json

- name: Run tests, against dist
run: yarn test

Expand Down
35 changes: 0 additions & 35 deletions docs/usage/MigratingToRedux.md

This file was deleted.

15 changes: 0 additions & 15 deletions jest.config.cjs

This file was deleted.

17 changes: 7 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
"format": "prettier --write \"{src,test}/**/*.{js,ts}\" \"**/*.md\"",
"format:check": "prettier --list-different \"{src,test}/**/*.{js,ts}\" \"**/*.md\"",
"lint": "eslint --ext js,ts src test",
"check-types": "tsc --noEmit",
"test": "jest",
"test:types": "tsc -p test/typescript",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"check-types": "tsc --noEmit && echo \"Types compiled\"",
"test": "vitest",
"test:types": "tsc -p test/typescript && echo \"Typetests passed\"",
"test:watch": "vitest --watch",
"test:cov": "vitest --coverage",
"build": "rollup -c",
"prepublishOnly": "yarn clean && yan check-types && yarn format:check && yarn lint && yarn test",
"examples:lint": "eslint --ext js,ts examples",
Expand All @@ -74,11 +74,9 @@
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-replace": "^5.0.0",
"@rollup/plugin-terser": "^0.4.0",
"@types/jest": "29.0.0",
"@types/node": "^18.7.16",
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"babel-jest": "^29.0.3",
"cross-env": "^7.0.3",
"eslint": "^8.23.0",
"eslint-config-react-app": "^7.0.1",
Expand All @@ -89,15 +87,14 @@
"eslint-plugin-react": "^7.31.8",
"eslint-plugin-react-hooks": "^4.6.0",
"glob": "^8.0.3",
"jest": "^29.0.3",
"netlify-plugin-cache": "^1.0.3",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"rollup": "^3.12.0",
"rollup-plugin-typescript2": "^0.34.1",
"rxjs": "^7.5.6",
"ts-jest": "^29.0.0",
"typescript": "^4.8.3"
"typescript": "^4.8.3",
"vitest": "^0.27.2"
},
"npmName": "redux",
"npmFileMap": [
Expand Down
43 changes: 21 additions & 22 deletions test/applyMiddleware.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
Action,
Store,
Dispatch
} from '../src'
} from 'redux'
import { vi } from 'vitest'
import * as reducers from './helpers/reducers'
import { addTodo, addTodoAsync, addTodoIfEmpty } from './helpers/actionCreators'
import { thunk } from './helpers/middleware'
Expand All @@ -34,7 +35,7 @@ describe('applyMiddleware', () => {
}
}

const spy = jest.fn()
const spy = vi.fn()
const store = applyMiddleware(test(spy), thunk)(createStore)(reducers.todos)

store.dispatch(addTodo('Use Redux'))
Expand All @@ -59,7 +60,7 @@ describe('applyMiddleware', () => {
}
}

const spy = jest.fn()
const spy = vi.fn()
const store = applyMiddleware(test(spy), thunk)(createStore)(reducers.todos)

// the typing for redux-thunk is super complex, so we will use an as unknown hack
Expand All @@ -71,7 +72,7 @@ describe('applyMiddleware', () => {
})
})

it('works with thunk middleware', done => {
it('works with thunk middleware', async () => {
const store = applyMiddleware(thunk)(createStore)(reducers.todos)

store.dispatch(addTodoIfEmpty('Hello') as any)
Expand Down Expand Up @@ -106,27 +107,25 @@ describe('applyMiddleware', () => {
const dispatchedValue = store.dispatch(
addTodoAsync('Maybe') as any
) as unknown as Promise<void>
dispatchedValue.then(() => {
expect(store.getState()).toEqual([
{
id: 1,
text: 'Hello'
},
{
id: 2,
text: 'World'
},
{
id: 3,
text: 'Maybe'
}
])
done()
})
await dispatchedValue
expect(store.getState()).toEqual([
{
id: 1,
text: 'Hello'
},
{
id: 2,
text: 'World'
},
{
id: 3,
text: 'Maybe'
}
])
})

it('passes through all arguments of dispatch calls from within middleware', () => {
const spy = jest.fn()
const spy = vi.fn()
const testCallArgs = ['test']

interface MultiDispatch<A extends Action = AnyAction> {
Expand Down
11 changes: 6 additions & 5 deletions test/combineReducers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
Reducer,
AnyAction,
__DO_NOT_USE__ActionTypes as ActionTypes
} from '../src'
} from 'redux'
import { vi } from 'vitest'

describe('Utils', () => {
describe('combineReducers', () => {
Expand Down Expand Up @@ -39,7 +40,7 @@ describe('Utils', () => {

it('warns if a reducer prop is undefined', () => {
const preSpy = console.error
const spy = jest.fn()
const spy = vi.fn()
console.error = spy

let isNotDefined: any
Expand Down Expand Up @@ -199,7 +200,7 @@ describe('Utils', () => {

it('warns if no reducers are passed to combineReducers', () => {
const preSpy = console.error
const spy = jest.fn()
const spy = vi.fn()
console.error = spy

const reducer = combineReducers({})
Expand All @@ -214,7 +215,7 @@ describe('Utils', () => {

it('warns if input state does not match reducer shape', () => {
const preSpy = console.error
const spy = jest.fn()
const spy = vi.fn()
const nullAction = undefined as unknown as AnyAction
console.error = spy

Expand Down Expand Up @@ -287,7 +288,7 @@ describe('Utils', () => {

it('only warns for unexpected keys once', () => {
const preSpy = console.error
const spy = jest.fn()
const spy = vi.fn()
console.error = spy
const nullAction = { type: '' }

Expand Down
Loading