Skip to content

Commit 29d5d88

Browse files
authored
Merge pull request #4483 from reduxjs/feature/local-tests
2 parents a5e4f95 + bad6237 commit 29d5d88

19 files changed

+61
-20
lines changed

.github/workflows/test.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,38 @@ jobs:
3535

3636
- name: Run test suite
3737
run: npm test
38+
39+
- name: Check build
40+
run: npm run build
41+
42+
test-types:
43+
name: Test Types with TypeScript ${{ matrix.ts }}
44+
45+
needs: [build]
46+
runs-on: ubuntu-latest
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
node: ['16.x']
51+
ts: ['4.1', '4.2', '4.3', '4.4', '4.5', '4.6', '4.7', '4.8', '4.9.2-rc']
52+
steps:
53+
- name: Checkout repo
54+
uses: actions/checkout@v2
55+
56+
- name: Use node ${{ matrix.node }}
57+
uses: actions/setup-node@v2
58+
with:
59+
node-version: ${{ matrix.node }}
60+
cache: 'npm'
61+
62+
- name: Install dependencies
63+
run: npm ci
64+
65+
- name: Install TypeScript ${{ matrix.ts }}
66+
run: npm i --save-dev typescript@${{ matrix.ts }}
67+
68+
- name: Test types
69+
run: |
70+
npm run tsc -- --version
71+
npm run check-types
72+
npm run test:types

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@
4848
"format:check": "prettier --list-different \"{src,test}/**/*.{js,ts}\" \"**/*.md\"",
4949
"lint": "eslint --ext js,ts src test",
5050
"check-types": "tsc --noEmit",
51-
"test": "jest && tsc -p test/typescript",
51+
"test": "jest",
5252
"test:types": "tsc -p test/typescript",
5353
"test:watch": "jest --watch",
5454
"test:cov": "jest --coverage",
5555
"build": "rollup -c",
56-
"pretest": "npm run build",
5756
"prepublishOnly": "npm run clean && npm run check-types && npm run format:check && npm run lint && npm test",
5857
"examples:lint": "eslint --ext js,ts examples",
59-
"examples:test": "cross-env CI=true babel-node examples/testAll.js"
58+
"examples:test": "cross-env CI=true babel-node examples/testAll.js",
59+
"tsc": "tsc"
6060
},
6161
"dependencies": {},
6262
"devDependencies": {

test/applyMiddleware.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
Action,
88
Store,
99
Dispatch
10-
} from '..'
10+
} from '../src'
1111
import * as reducers from './helpers/reducers'
1212
import { addTodo, addTodoAsync, addTodoIfEmpty } from './helpers/actionCreators'
1313
import { thunk } from './helpers/middleware'

test/bindActionCreators.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { bindActionCreators, createStore, ActionCreator, Store } from '..'
1+
import { bindActionCreators, createStore, ActionCreator, Store } from '../src'
22
import { todos } from './helpers/reducers'
33
import * as actionCreators from './helpers/actionCreators'
44

test/combineReducers.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
Reducer,
66
AnyAction,
77
__DO_NOT_USE__ActionTypes as ActionTypes
8-
} from '..'
8+
} from '../src'
99

1010
describe('Utils', () => {
1111
describe('combineReducers', () => {

test/compose.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { compose } from '..'
1+
import { compose } from '../src'
22

33
describe('Utils', () => {
44
describe('compose', () => {

test/createStore.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { createStore, combineReducers, StoreEnhancer, Action, Store } from '..'
1+
import {
2+
createStore,
3+
combineReducers,
4+
StoreEnhancer,
5+
Action,
6+
Store
7+
} from '../src'
28
import {
39
addTodo,
410
dispatchInMiddle,

test/helpers/actionCreators.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
THROW_ERROR,
88
UNKNOWN_ACTION
99
} from './actionTypes'
10-
import { Action, AnyAction, Dispatch } from '../..'
10+
import { Action, AnyAction, Dispatch } from '../../src'
1111

1212
export function addTodo(text: string): AnyAction {
1313
return { type: ADD_TODO, text }

test/helpers/middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MiddlewareAPI, Dispatch, AnyAction } from '../..'
1+
import { MiddlewareAPI, Dispatch, AnyAction } from '../../src'
22

33
type ThunkAction<T extends any = any> = T extends AnyAction
44
? AnyAction

test/helpers/reducers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
UNSUBSCRIBE_IN_MIDDLE,
77
THROW_ERROR
88
} from './actionTypes'
9-
import { AnyAction } from '../..'
9+
import { AnyAction } from '../../src'
1010

1111
function id(state: { id: number }[]) {
1212
return (

test/typescript/actionCreators.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
Dispatch,
55
bindActionCreators,
66
ActionCreatorsMapObject
7-
} from '../..'
7+
} from '../../src'
88

99
interface AddTodoAction extends Action {
1010
text: string

test/typescript/actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Action as ReduxAction } from '../..'
1+
import { Action as ReduxAction } from '../../src'
22

33
namespace FSA {
44
interface Action<P> extends ReduxAction {

test/typescript/compose.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { compose } from '../..'
1+
import { compose } from '../../src'
22

33
// adapted from DefinitelyTyped/compose-function
44

test/typescript/dispatch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Dispatch } from '../..'
1+
import { Dispatch } from '../../src'
22

33
/**
44
* Default Dispatch type accepts any object with `type` property.

test/typescript/enhancers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
Reducer,
66
createStore,
77
Store
8-
} from '../..'
8+
} from '../../src'
99

1010
interface State {
1111
someField: 'string'

test/typescript/injectedDispatch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Dispatch, Action } from '../..'
1+
import { Dispatch, Action } from '../../src'
22

33
interface Component<P> {
44
props: P

test/typescript/middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
Reducer,
88
Action,
99
AnyAction
10-
} from '../..'
10+
} from '../../src'
1111

1212
/**
1313
* Logger middleware doesn't add any extra types to dispatch, just logs actions

test/typescript/reducers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Reducer, Action, combineReducers, ReducersMapObject } from '../..'
1+
import { Reducer, Action, combineReducers, ReducersMapObject } from '../../src'
22

33
/**
44
* Simple reducer definition with no action shape checks.

test/typescript/store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
Unsubscribe,
88
Observer,
99
ExtendState
10-
} from '../..'
10+
} from '../../src'
1111
import 'symbol-observable'
1212

1313
type BrandedString = string & { _brand: 'type' }

0 commit comments

Comments
 (0)