Skip to content

Commit e62f478

Browse files
committed
Add path aliases and test against dist
1 parent bdeb473 commit e62f478

9 files changed

+54
-20
lines changed

.github/workflows/test.yml

+36-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ jobs:
2525
- name: Install dependencies
2626
run: yarn install
2727

28-
- name: Run test suite
29-
run: yarn test
30-
3128
- name: Collect coverage
3229
run: yarn coverage
3330

@@ -42,6 +39,42 @@ jobs:
4239
name: package
4340
path: ./package.tgz
4441

42+
test-dist:
43+
name: Test against dist
44+
needs: [build]
45+
runs-on: ubuntu-latest
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
node: ['20.x']
50+
steps:
51+
- name: Checkout repo
52+
uses: actions/checkout@v4
53+
54+
- name: Use node ${{ matrix.node }}
55+
uses: actions/setup-node@v4
56+
with:
57+
node-version: ${{ matrix.node }}
58+
cache: 'yarn'
59+
60+
- name: Install deps
61+
run: yarn install
62+
63+
- uses: actions/download-artifact@v4
64+
with:
65+
name: package
66+
path: .
67+
68+
- run: ls -lah
69+
70+
- name: Install build artifact
71+
run: yarn add ./package.tgz
72+
73+
- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./vitest.config.mts
74+
75+
- name: Run tests, against dist
76+
run: yarn test
77+
4578
test-types:
4679
name: Test Types with TypeScript ${{ matrix.ts }}
4780

test/typetests/connect-mapstate-mapdispatch.test-d.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import type { ActionCreator, Dispatch } from 'redux'
33
import type {
44
MapDispatchToProps,
55
ReactReduxContextValue,
6-
} from '../../src/index'
7-
import { connect } from '../../src/index'
6+
} from 'react-redux'
7+
import { connect } from 'react-redux'
88

99
// Test cases written in a way to isolate types and variables and verify the
1010
// output of `connect` to make sure the signature is what is expected

test/typetests/connect-options-and-issues.test-d.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import PropTypes from 'prop-types'
22
import React from 'react'
3-
import type { ActionCreator, AnyAction, Dispatch, Reducer, Store } from 'redux'
4-
import { createStore } from 'redux'
53
import type {
64
Connect,
75
ConnectedProps,
86
DispatchProp,
97
MapStateToProps,
108
ReactReduxContextValue,
11-
} from '../../src/index'
12-
import { Provider, ReactReduxContext, connect } from '../../src/index'
9+
} from 'react-redux'
10+
import { Provider, ReactReduxContext, connect } from 'react-redux'
11+
import type { ActionCreator, AnyAction, Dispatch, Reducer, Store } from 'redux'
12+
import { createStore } from 'redux'
1313

1414
// Test cases written in a way to isolate types and variables and verify the
1515
// output of `connect` to make sure the signature is what is expected

test/typetests/hooks.test-d.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
Selector,
77
TypedUseSelectorHook,
88
UseSelector,
9-
} from '../../src/index'
9+
} from 'react-redux'
1010
import {
1111
createDispatchHook,
1212
createSelectorHook,
@@ -15,7 +15,7 @@ import {
1515
useDispatch,
1616
useSelector,
1717
useStore,
18-
} from '../../src/index'
18+
} from 'react-redux'
1919
import type { AppDispatch, RootState } from './counterApp'
2020
import { incrementAsync } from './counterApp'
2121

test/typetests/hooks.withTypes.test-d.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useDispatch, useSelector, useStore } from '../../src/index'
1+
import { useDispatch, useSelector, useStore } from 'react-redux'
22
import type { AppDispatch, AppStore, RootState } from './counterApp'
33
import { incrementAsync } from './counterApp'
44

test/typetests/provider.test-d.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { Provider } from 'react-redux'
12
import type { Store } from 'redux'
2-
import { Provider } from '../../src'
33

44
declare const store: Store<{ foo: string }>
55

test/typetests/react-redux-types.test-d.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@ import { bindActionCreators } from '@reduxjs/toolkit'
33
import type { ReactElement } from 'react'
44
import React, { Component } from 'react'
55
import { createRoot } from 'react-dom/client'
6-
import type {
7-
ConnectedProps,
8-
DispatchProp,
9-
MapStateToProps,
10-
} from '../../src/index'
11-
import { Provider, connect } from '../../src/index'
6+
import type { ConnectedProps, DispatchProp, MapStateToProps } from 'react-redux'
7+
import { Provider, connect } from 'react-redux'
128
import type { CounterState } from './counterApp'
139
import { increment } from './counterApp'
1410

tsconfig.base.json

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
"noFallthroughCasesInSwitch": true,
1616
"noUnusedLocals": false,
1717
"noUnusedParameters": false,
18+
"paths": {
19+
"@internal/*": ["./src/*"],
20+
"react-redux": ["./src/index.ts"] // @remap-prod-remove-line
21+
},
1822
"resolveJsonModule": true,
1923
"skipLibCheck": true,
2024
"strict": true,

vitest.config.mts

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ export default defineConfig({
1212
setupFiles: ['test/setup.ts'],
1313
globals: true,
1414
alias: {
15+
'react-redux': new URL('src/index.ts', import.meta.url).pathname, // @remap-prod-remove-line
1516
// this mapping is disabled as we want `dist` imports in the tests only to be used for "type-only" imports which don't play a role for jest
16-
'@internal': path.join(__dirname, 'src'),
17+
'@internal': new URL('src', import.meta.url).pathname,
1718
},
1819
},
1920
})

0 commit comments

Comments
 (0)