Skip to content

Commit 0ff4d29

Browse files
committed
Run tests against dist folder
1 parent c3af089 commit 0ff4d29

24 files changed

+50
-29
lines changed

.github/workflows/test.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ jobs:
4040
- name: Install deps
4141
run: yarn install
4242

43+
- name: Build
44+
run: yarn build
45+
4346
- name: Pack
4447
run: yarn pack
4548

@@ -79,6 +82,14 @@ jobs:
7982
- name: Install build artifact
8083
run: yarn add ./package.tgz
8184

85+
- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.json ./jest.config.cjs ./test/tsconfig.json ./test/typescript/tsconfig.json
86+
87+
- run: cat ./tsconfig.json
88+
- run: cat ./test/tsconfig.json
89+
- run: cat ./test/typescript/tsconfig.json
90+
91+
- run: ls -lah ./node_modules/redux
92+
8293
- name: Run tests, against dist
8394
run: yarn test
8495

jest.config.cjs

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ module.exports = {
44
testEnvironment: 'node',
55
testRegex: '(/test/.*\\.spec\\.ts)$',
66
coverageProvider: 'v8',
7+
moduleNameMapper: {
8+
'^redux$': '<rootDir>/src/index.ts' // @remap-prod-remove-line
9+
'^@internal/(.*)$': '<rootDir>/src/$1'
10+
},
711
transform: {
812
'\\.ts$': [
913
'ts-jest',

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
"format": "prettier --write \"{src,test}/**/*.{js,ts}\" \"**/*.md\"",
4848
"format:check": "prettier --list-different \"{src,test}/**/*.{js,ts}\" \"**/*.md\"",
4949
"lint": "eslint --ext js,ts src test",
50-
"check-types": "tsc --noEmit",
50+
"check-types": "tsc --noEmit && echo \"Types compiled\"",
5151
"test": "jest",
52-
"test:types": "tsc -p test/typescript",
52+
"test:types": "tsc -p test/typescript && echo \"Typetests passed\"",
5353
"test:watch": "jest --watch",
5454
"test:cov": "jest --coverage",
5555
"build": "rollup -c",

test/applyMiddleware.spec.ts

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

test/combineReducers.spec.ts

+1-1
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 '../src'
8+
} from 'redux'
99

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

test/createStore.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
StoreEnhancer,
55
Action,
66
Store
7-
} from '../src'
7+
} from 'redux'
88
import {
99
addTodo,
1010
dispatchInMiddle,

test/helpers/actionCreators.ts

+1-1
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 '../../src'
10+
import { Action, AnyAction, Dispatch } from 'redux'
1111

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

test/helpers/middleware.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MiddlewareAPI, Dispatch, AnyAction } from '../../src'
1+
import { MiddlewareAPI, Dispatch, AnyAction } from 'redux'
22

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

test/helpers/reducers.ts

+1-1
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 '../../src'
9+
import { AnyAction } from 'redux'
1010

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

test/tsconfig.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
"baseUrl": ".",
1414
"skipLibCheck": true,
1515
"noImplicitReturns": false,
16-
"noUnusedLocals": false
16+
"noUnusedLocals": false,
17+
"paths": {
18+
"redux": ["../src/index.ts"], // @remap-prod-remove-line
19+
"@internal/*": ["../src/*"]
20+
}
1721
},
1822
"include": ["**/*.spec.ts"]
1923
}

test/typescript/actionCreators.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
Dispatch,
55
bindActionCreators,
66
ActionCreatorsMapObject
7-
} from '../../src'
7+
} from 'redux'
88

99
interface AddTodoAction extends Action {
1010
text: string

test/typescript/actions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Action as ReduxAction } from '../../src'
1+
import { Action as ReduxAction } from 'redux'
22

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

test/typescript/compose.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { compose } from '../../src'
1+
import { compose } from 'redux'
22

33
// adapted from DefinitelyTyped/compose-function
44

test/typescript/dispatch.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Dispatch } from '../../src'
1+
import { Dispatch } from 'redux'
22

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

test/typescript/enhancers.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
StoreEnhancer,
3-
Action,
4-
AnyAction,
5-
Reducer,
6-
createStore
7-
} from '../../src'
1+
import { StoreEnhancer, Action, AnyAction, Reducer, createStore } from 'redux'
82

93
interface State {
104
someField: 'string'

test/typescript/injectedDispatch.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Dispatch, Action } from '../../src'
1+
import { Dispatch, Action } from 'redux'
22

33
interface Component<P> {
44
props: P

test/typescript/middleware.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
Reducer,
88
Action,
99
AnyAction
10-
} from '../../src'
10+
} from 'redux'
1111

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

test/typescript/reducers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Reducer, Action, combineReducers, ReducersMapObject } from '../../src'
1+
import { Reducer, Action, combineReducers, ReducersMapObject } from 'redux'
22

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

test/typescript/store.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
StoreEnhancer,
77
Unsubscribe,
88
Observer
9-
} from '../../src'
9+
} from 'redux'
1010
import 'symbol-observable'
1111

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

test/typescript/tsconfig.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
"skipLibCheck": true,
1515
"noImplicitReturns": false,
1616
"noUnusedLocals": false,
17-
"noUnusedParameters": false
17+
"noUnusedParameters": false,
18+
"paths": {
19+
"redux": ["../../src/index.ts"], // @remap-prod-remove-line
20+
"@internal/*": ["../../src/*"]
21+
}
1822
},
1923
"include": ["."]
2024
}

test/utils/formatProdErrorMessage.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import formatProdErrorMessage from '../../src/utils/formatProdErrorMessage'
1+
import formatProdErrorMessage from '@internal/utils/formatProdErrorMessage'
22

33
describe('formatProdErrorMessage', () => {
44
it('returns message with expected code references', () => {

test/utils/isPlainObject.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from 'expect'
2-
import isPlainObject from '../../src/utils/isPlainObject'
2+
import isPlainObject from '@internal/utils/isPlainObject'
33
import vm from 'vm'
44

55
describe('isPlainObject', () => {

test/utils/warning.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-console */
2-
import warning from '../../src/utils/warning'
2+
import warning from '@internal/utils/warning'
33

44
describe('Utils', () => {
55
describe('warning', () => {

tsconfig.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
"removeComments": false,
1515
"noUnusedLocals": true,
1616
"noUnusedParameters": true,
17-
"baseUrl": "./"
17+
"baseUrl": "./",
18+
"paths": {
19+
"redux": ["src/index.ts"], // @remap-prod-remove-line
20+
"@internal/*": ["src/*"]
21+
}
1822
},
1923
"include": ["src/**/*"],
2024
"exclude": ["node_modules", "dist"]

0 commit comments

Comments
 (0)