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 from source instead of building first #4483

Merged
merged 2 commits into from
Feb 12, 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
35 changes: 35 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,38 @@ jobs:

- name: Run test suite
run: npm test

- name: Check build
run: npm run build

test-types:
name: Test Types with TypeScript ${{ matrix.ts }}

needs: [build]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: ['16.x']
ts: ['4.1', '4.2', '4.3', '4.4', '4.5', '4.6', '4.7', '4.8', '4.9.2-rc']
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Use node ${{ matrix.node }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Install TypeScript ${{ matrix.ts }}
run: npm i --save-dev typescript@${{ matrix.ts }}

- name: Test types
run: |
npm run tsc -- --version
npm run check-types
npm run test:types
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@
"format:check": "prettier --list-different \"{src,test}/**/*.{js,ts}\" \"**/*.md\"",
"lint": "eslint --ext js,ts src test",
"check-types": "tsc --noEmit",
"test": "jest && tsc -p test/typescript",
"test": "jest",
"test:types": "tsc -p test/typescript",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"build": "rollup -c",
"pretest": "npm run build",
"prepublishOnly": "npm run clean && npm run check-types && npm run format:check && npm run lint && npm test",
"examples:lint": "eslint --ext js,ts examples",
"examples:test": "cross-env CI=true babel-node examples/testAll.js"
"examples:test": "cross-env CI=true babel-node examples/testAll.js",
"tsc": "tsc"
},
"dependencies": {},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion test/applyMiddleware.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Action,
Store,
Dispatch
} from '..'
} from '../src'
import * as reducers from './helpers/reducers'
import { addTodo, addTodoAsync, addTodoIfEmpty } from './helpers/actionCreators'
import { thunk } from './helpers/middleware'
Expand Down
2 changes: 1 addition & 1 deletion test/bindActionCreators.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bindActionCreators, createStore, ActionCreator, Store } from '..'
import { bindActionCreators, createStore, ActionCreator, Store } from '../src'
import { todos } from './helpers/reducers'
import * as actionCreators from './helpers/actionCreators'

Expand Down
2 changes: 1 addition & 1 deletion test/combineReducers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Reducer,
AnyAction,
__DO_NOT_USE__ActionTypes as ActionTypes
} from '..'
} from '../src'

describe('Utils', () => {
describe('combineReducers', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/compose.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { compose } from '..'
import { compose } from '../src'

describe('Utils', () => {
describe('compose', () => {
Expand Down
8 changes: 7 additions & 1 deletion test/createStore.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { createStore, combineReducers, StoreEnhancer, Action, Store } from '..'
import {
createStore,
combineReducers,
StoreEnhancer,
Action,
Store
} from '../src'
import {
addTodo,
dispatchInMiddle,
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/actionCreators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
THROW_ERROR,
UNKNOWN_ACTION
} from './actionTypes'
import { Action, AnyAction, Dispatch } from '../..'
import { Action, AnyAction, Dispatch } from '../../src'

export function addTodo(text: string): AnyAction {
return { type: ADD_TODO, text }
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MiddlewareAPI, Dispatch, AnyAction } from '../..'
import { MiddlewareAPI, Dispatch, AnyAction } from '../../src'

type ThunkAction<T extends any = any> = T extends AnyAction
? AnyAction
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
UNSUBSCRIBE_IN_MIDDLE,
THROW_ERROR
} from './actionTypes'
import { AnyAction } from '../..'
import { AnyAction } from '../../src'

function id(state: { id: number }[]) {
return (
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/actionCreators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Dispatch,
bindActionCreators,
ActionCreatorsMapObject
} from '../..'
} from '../../src'

interface AddTodoAction extends Action {
text: string
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Action as ReduxAction } from '../..'
import { Action as ReduxAction } from '../../src'

namespace FSA {
interface Action<P> extends ReduxAction {
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/compose.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { compose } from '../..'
import { compose } from '../../src'

// adapted from DefinitelyTyped/compose-function

Expand Down
2 changes: 1 addition & 1 deletion test/typescript/dispatch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Dispatch } from '../..'
import { Dispatch } from '../../src'

/**
* Default Dispatch type accepts any object with `type` property.
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/enhancers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Reducer,
createStore,
Store
} from '../..'
} from '../../src'

interface State {
someField: 'string'
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/injectedDispatch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Dispatch, Action } from '../..'
import { Dispatch, Action } from '../../src'

interface Component<P> {
props: P
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Reducer,
Action,
AnyAction
} from '../..'
} from '../../src'

/**
* Logger middleware doesn't add any extra types to dispatch, just logs actions
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/reducers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Reducer, Action, combineReducers, ReducersMapObject } from '../..'
import { Reducer, Action, combineReducers, ReducersMapObject } from '../../src'

/**
* Simple reducer definition with no action shape checks.
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Unsubscribe,
Observer,
ExtendState
} from '../..'
} from '../../src'
import 'symbol-observable'

type BrandedString = string & { _brand: 'type' }
Expand Down