Skip to content

Integrate RTKQ tests #1012

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

Merged
merged 10 commits into from
Apr 24, 2021
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
node_modules
# Dist and query are both build output folders
dist
query
!query/
# But don't ignore the RTK Query source
!src/query/
lib
es
yarn.lock
Expand Down
2 changes: 1 addition & 1 deletion api-extractor.query-react.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
*/
"mainEntryPointFilePath": "dist/query/react.d.ts",
"mainEntryPointFilePath": "dist/query/react/index.d.ts",
//"mainEntryPointFilePath": "/home/weber/tmp/rtk-origin-master/dist/index.d.ts",

/**
Expand Down
13 changes: 12 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
module.exports = {
setupFilesAfterEnv: ['./jest.setup.js'],
testPathIgnorePatterns: ['<rootDir>/query/*'],
testPathIgnorePatterns: ['<rootDir>/query-old/*'],
moduleNameMapper: {
'^@reduxjs/toolkit$': '<rootDir>/src/index.ts',
'^@reduxjs/toolkit/query$': '<rootDir>/src/query/index.ts',
'^@reduxjs/toolkit/query/react$': '<rootDir>/src/query/react/index.ts',
'^@internal/(.*)$': '<rootDir>/src/query/*',
},
globals: {
'ts-jest': {
tsconfig: 'tsconfig.test.json',
},
},
}
14 changes: 13 additions & 1 deletion jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
process.on('unhandledRejection', error => {
//@ts-ignore
const nodeFetch = require('node-fetch')
//@ts-ignore
global.fetch = nodeFetch
//@ts-ignore
global.Request = nodeFetch.Request
const { server } = require('./src/query/tests/mocks/server')

beforeAll(() => server.listen({ onUnhandledRequest: 'error' }))
afterEach(() => server.resetHandlers())
afterAll(() => server.close())

process.on('unhandledRejection', (error) => {
// eslint-disable-next-line no-undef
fail(error)
})
Loading