From 3cc237275233c17f8535ff15c6d13dc2f9221c0b Mon Sep 17 00:00:00 2001 From: Josh Ellis Date: Sat, 9 Jan 2021 11:58:44 +0000 Subject: [PATCH 1/3] refactor: move tests to specificly related folders --- .gitignore | 12 +++++++++++- jest.config.js | 4 ++-- {test => src/__tests__}/tsconfig.json | 4 ++-- .../dom/__tests__/asyncHook.test.ts | 2 +- .../dom/__tests__/autoCleanup.disabled.test.ts | 4 ++-- .../dom/__tests__/autoCleanup.noAfterEach.test.ts | 4 ++-- .../dom/__tests__/autoCleanup.test.ts | 2 +- .../cleanup.ts => src/dom/__tests__/cleanup.test.ts | 2 +- .../dom/__tests__/customHook.test.ts | 2 +- .../dom/__tests__/errorHook.test.ts | 2 +- .../dom/__tests__/resultHistory.test.ts | 2 +- .../dom/__tests__/suspenseHook.test.ts | 2 +- .../dom/__tests__/useContext.test.tsx | 2 +- .../dom/__tests__/useEffect.test.ts | 2 +- .../useMemo.ts => src/dom/__tests__/useMemo.test.ts | 2 +- .../dom/__tests__/useReducer.test.ts | 2 +- .../useRef.ts => src/dom/__tests__/useRef.test.ts | 2 +- .../dom/__tests__/useState.test.ts | 2 +- .../native/__tests__/asyncHook.test.ts | 2 +- .../native/__tests__/autoCleanup.disabled.test.ts | 4 ++-- .../native/__tests__/autoCleanup.noAfterEach.test.ts | 4 ++-- .../native/__tests__/autoCleanup.test.ts | 2 +- .../native/__tests__/cleanup.test.ts | 2 +- .../native/__tests__/customHook.test.ts | 2 +- .../native/__tests__/errorHook.test.ts | 2 +- .../native/__tests__/resultHistory.test.ts | 2 +- .../native/__tests__/suspenseHook.test.ts | 2 +- .../native/__tests__/useContext.test.tsx | 2 +- .../native/__tests__/useEffect.test.ts | 2 +- .../native/__tests__/useMemo.test.ts | 2 +- .../native/__tests__/useReducer.test.ts | 2 +- .../useRef.ts => src/native/__tests__/useRef.test.ts | 2 +- .../native/__tests__/useState.test.ts | 2 +- .../server/__tests__/asyncHook.test.ts | 2 +- .../server/__tests__/autoCleanup.disabled.test.ts | 4 ++-- .../server/__tests__/autoCleanup.noAfterEach.test.ts | 4 ++-- .../server/__tests__/autoCleanup.test.ts | 2 +- .../server/__tests__/cleanup.test.ts | 2 +- .../server/__tests__/customHook.test.ts | 2 +- .../server/__tests__/errorHook.test.ts | 2 +- .../server/__tests__/hydrationErrors.test.ts | 2 +- .../server/__tests__/useContext.test.tsx | 2 +- .../server/__tests__/useEffect.test.ts | 2 +- .../server/__tests__/useMemo.test.ts | 2 +- .../server/__tests__/useReducer.test.ts | 2 +- .../useRef.ts => src/server/__tests__/useRef.test.ts | 2 +- .../server/__tests__/useState.test.ts | 2 +- tsconfig.json | 3 ++- 48 files changed, 67 insertions(+), 56 deletions(-) rename {test => src/__tests__}/tsconfig.json (52%) rename test/dom/asyncHook.ts => src/dom/__tests__/asyncHook.test.ts (99%) rename test/native/autoCleanup.disabled.ts => src/dom/__tests__/autoCleanup.disabled.test.ts (84%) rename test/server/autoCleanup.noAfterEach.ts => src/dom/__tests__/autoCleanup.noAfterEach.test.ts (86%) rename test/dom/autoCleanup.ts => src/dom/__tests__/autoCleanup.test.ts (92%) rename test/dom/cleanup.ts => src/dom/__tests__/cleanup.test.ts (99%) rename test/dom/customHook.ts => src/dom/__tests__/customHook.test.ts (93%) rename test/dom/errorHook.ts => src/dom/__tests__/errorHook.test.ts (98%) rename test/dom/resultHistory.ts => src/dom/__tests__/resultHistory.test.ts (94%) rename test/dom/suspenseHook.ts => src/dom/__tests__/suspenseHook.test.ts (96%) rename test/dom/useContext.tsx => src/dom/__tests__/useContext.test.tsx (97%) rename test/dom/useEffect.ts => src/dom/__tests__/useEffect.test.ts (97%) rename test/dom/useMemo.ts => src/dom/__tests__/useMemo.test.ts (96%) rename test/dom/useReducer.ts => src/dom/__tests__/useReducer.test.ts (91%) rename test/dom/useRef.ts => src/dom/__tests__/useRef.test.ts (94%) rename test/dom/useState.ts => src/dom/__tests__/useState.test.ts (91%) rename test/native/asyncHook.ts => src/native/__tests__/asyncHook.test.ts (99%) rename test/dom/autoCleanup.disabled.ts => src/native/__tests__/autoCleanup.disabled.test.ts (84%) rename test/dom/autoCleanup.noAfterEach.ts => src/native/__tests__/autoCleanup.noAfterEach.test.ts (86%) rename test/native/autoCleanup.ts => src/native/__tests__/autoCleanup.test.ts (91%) rename test/native/cleanup.ts => src/native/__tests__/cleanup.test.ts (99%) rename test/native/customHook.ts => src/native/__tests__/customHook.test.ts (93%) rename test/native/errorHook.ts => src/native/__tests__/errorHook.test.ts (98%) rename test/native/resultHistory.ts => src/native/__tests__/resultHistory.test.ts (94%) rename test/native/suspenseHook.ts => src/native/__tests__/suspenseHook.test.ts (96%) rename test/native/useContext.tsx => src/native/__tests__/useContext.test.tsx (97%) rename test/native/useEffect.ts => src/native/__tests__/useEffect.test.ts (96%) rename test/native/useMemo.ts => src/native/__tests__/useMemo.test.ts (96%) rename test/native/useReducer.ts => src/native/__tests__/useReducer.test.ts (90%) rename test/native/useRef.ts => src/native/__tests__/useRef.test.ts (94%) rename test/native/useState.ts => src/native/__tests__/useState.test.ts (91%) rename test/server/asyncHook.ts => src/server/__tests__/asyncHook.test.ts (99%) rename test/server/autoCleanup.disabled.ts => src/server/__tests__/autoCleanup.disabled.test.ts (84%) rename test/native/autoCleanup.noAfterEach.ts => src/server/__tests__/autoCleanup.noAfterEach.test.ts (86%) rename test/server/autoCleanup.ts => src/server/__tests__/autoCleanup.test.ts (94%) rename test/server/cleanup.ts => src/server/__tests__/cleanup.test.ts (96%) rename test/server/customHook.ts => src/server/__tests__/customHook.test.ts (93%) rename test/server/errorHook.ts => src/server/__tests__/errorHook.test.ts (98%) rename test/server/hydrationErrors.ts => src/server/__tests__/hydrationErrors.test.ts (94%) rename test/server/useContext.tsx => src/server/__tests__/useContext.test.tsx (96%) rename test/server/useEffect.ts => src/server/__tests__/useEffect.test.ts (94%) rename test/server/useMemo.ts => src/server/__tests__/useMemo.test.ts (97%) rename test/server/useReducer.ts => src/server/__tests__/useReducer.test.ts (91%) rename test/server/useRef.ts => src/server/__tests__/useRef.test.ts (94%) rename test/server/useState.ts => src/server/__tests__/useState.test.ts (94%) diff --git a/.gitignore b/.gitignore index 2236836e..33e40a57 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ +# node node_modules -coverage + +# build generated lib dom native @@ -7,4 +9,12 @@ server pure .docz site + +# tests (need the !files because of the build generated above) +coverage +!src/dom +!src/native +!src/server + +# settings from IDE .vscode diff --git a/jest.config.js b/jest.config.js index d9ce8bbb..588591dd 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,6 +2,6 @@ const { jest: jestConfig } = require('kcd-scripts/config') module.exports = Object.assign(jestConfig, { - roots: ['/src', '/test'], - testMatch: ['/test/**/*.(ts|tsx|js)'] + roots: ['/src'], + testMatch: ['/**/__tests__/*.(ts|tsx|js)'] }) diff --git a/test/tsconfig.json b/src/__tests__/tsconfig.json similarity index 52% rename from test/tsconfig.json rename to src/__tests__/tsconfig.json index bbb2c4c6..96b00ced 100644 --- a/test/tsconfig.json +++ b/src/__tests__/tsconfig.json @@ -1,8 +1,8 @@ { - "extends": "../tsconfig", + "extends": "../../tsconfig", "compilerOptions": { "declaration": false }, "exclude": [], - "include": ["./**/*.ts"] + "include": ["**/*.test.(ts|tsx)"] } diff --git a/test/dom/asyncHook.ts b/src/dom/__tests__/asyncHook.test.ts similarity index 99% rename from test/dom/asyncHook.ts rename to src/dom/__tests__/asyncHook.test.ts index 20559e4c..b9371ed3 100644 --- a/test/dom/asyncHook.ts +++ b/src/dom/__tests__/asyncHook.test.ts @@ -1,5 +1,5 @@ import { useState, useRef, useEffect } from 'react' -import { renderHook } from '../../src/dom' +import { renderHook } from '../index' describe('async hook tests', () => { const useSequence = (...values: string[]) => { diff --git a/test/native/autoCleanup.disabled.ts b/src/dom/__tests__/autoCleanup.disabled.test.ts similarity index 84% rename from test/native/autoCleanup.disabled.ts rename to src/dom/__tests__/autoCleanup.disabled.test.ts index b43794d5..3eafbe5a 100644 --- a/test/native/autoCleanup.disabled.ts +++ b/src/dom/__tests__/autoCleanup.disabled.test.ts @@ -1,6 +1,6 @@ import { useEffect } from 'react' -import { ReactHooksRenderer } from 'types' +import { ReactHooksRenderer } from '../../types/react' // This verifies that if RHTL_SKIP_AUTO_CLEANUP is set // then we DON'T auto-wire up the afterEach for folks @@ -11,7 +11,7 @@ describe('skip auto cleanup (disabled) tests', () => { beforeAll(() => { process.env.RHTL_SKIP_AUTO_CLEANUP = 'true' // eslint-disable-next-line @typescript-eslint/no-var-requires - renderHook = (require('../../src/native') as ReactHooksRenderer).renderHook + renderHook = (require('../index') as ReactHooksRenderer).renderHook }) test('first', () => { diff --git a/test/server/autoCleanup.noAfterEach.ts b/src/dom/__tests__/autoCleanup.noAfterEach.test.ts similarity index 86% rename from test/server/autoCleanup.noAfterEach.ts rename to src/dom/__tests__/autoCleanup.noAfterEach.test.ts index 180dbea3..053cecc5 100644 --- a/test/server/autoCleanup.noAfterEach.ts +++ b/src/dom/__tests__/autoCleanup.noAfterEach.test.ts @@ -1,6 +1,6 @@ import { useEffect } from 'react' -import { ReactHooksRenderer } from 'types' +import { ReactHooksRenderer } from '../../types/react' // This verifies that if RHTL_SKIP_AUTO_CLEANUP is set // then we DON'T auto-wire up the afterEach for folks @@ -13,7 +13,7 @@ describe('skip auto cleanup (no afterEach) tests', () => { // eslint-disable-next-line no-global-assign afterEach = false // eslint-disable-next-line @typescript-eslint/no-var-requires - renderHook = (require('../../src/server') as ReactHooksRenderer).renderHook + renderHook = (require('../index') as ReactHooksRenderer).renderHook }) test('first', () => { diff --git a/test/dom/autoCleanup.ts b/src/dom/__tests__/autoCleanup.test.ts similarity index 92% rename from test/dom/autoCleanup.ts rename to src/dom/__tests__/autoCleanup.test.ts index b5585350..dca4ca1e 100644 --- a/test/dom/autoCleanup.ts +++ b/src/dom/__tests__/autoCleanup.test.ts @@ -1,5 +1,5 @@ import { useEffect } from 'react' -import { renderHook } from '../../src/dom' +import { renderHook } from '../index' // This verifies that by importing RHTL in an // environment which supports afterEach (like Jest) diff --git a/test/dom/cleanup.ts b/src/dom/__tests__/cleanup.test.ts similarity index 99% rename from test/dom/cleanup.ts rename to src/dom/__tests__/cleanup.test.ts index aafa877b..20a0f267 100644 --- a/test/dom/cleanup.ts +++ b/src/dom/__tests__/cleanup.test.ts @@ -1,5 +1,5 @@ import { useEffect } from 'react' -import { renderHook, cleanup, addCleanup, removeCleanup } from '../../src/dom/pure' +import { renderHook, cleanup, addCleanup, removeCleanup } from '../pure' describe('cleanup tests', () => { test('should flush effects on cleanup', async () => { diff --git a/test/dom/customHook.ts b/src/dom/__tests__/customHook.test.ts similarity index 93% rename from test/dom/customHook.ts rename to src/dom/__tests__/customHook.test.ts index ab1b859d..fe617465 100644 --- a/test/dom/customHook.ts +++ b/src/dom/__tests__/customHook.test.ts @@ -1,5 +1,5 @@ import { useState, useCallback } from 'react' -import { renderHook, act } from '../../src/dom' +import { renderHook, act } from '../index' describe('custom hook tests', () => { function useCounter() { diff --git a/test/dom/errorHook.ts b/src/dom/__tests__/errorHook.test.ts similarity index 98% rename from test/dom/errorHook.ts rename to src/dom/__tests__/errorHook.test.ts index b0a5ba8c..f2ae6165 100644 --- a/test/dom/errorHook.ts +++ b/src/dom/__tests__/errorHook.test.ts @@ -1,5 +1,5 @@ import { useState, useEffect } from 'react' -import { renderHook } from '../../src/dom' +import { renderHook } from '../index' describe('error hook tests', () => { function useError(throwError?: boolean) { diff --git a/test/dom/resultHistory.ts b/src/dom/__tests__/resultHistory.test.ts similarity index 94% rename from test/dom/resultHistory.ts rename to src/dom/__tests__/resultHistory.test.ts index 68c84741..1d56f33d 100644 --- a/test/dom/resultHistory.ts +++ b/src/dom/__tests__/resultHistory.test.ts @@ -1,4 +1,4 @@ -import { renderHook } from '../../src/dom' +import { renderHook } from '../index' describe('result history tests', () => { let count = 0 diff --git a/test/dom/suspenseHook.ts b/src/dom/__tests__/suspenseHook.test.ts similarity index 96% rename from test/dom/suspenseHook.ts rename to src/dom/__tests__/suspenseHook.test.ts index 174d70b2..030661db 100644 --- a/test/dom/suspenseHook.ts +++ b/src/dom/__tests__/suspenseHook.test.ts @@ -1,4 +1,4 @@ -import { renderHook } from '../../src/dom' +import { renderHook } from '../index' describe('suspense hook tests', () => { const cache: { value?: Promise | string | Error } = {} diff --git a/test/dom/useContext.tsx b/src/dom/__tests__/useContext.test.tsx similarity index 97% rename from test/dom/useContext.tsx rename to src/dom/__tests__/useContext.test.tsx index 0f88c548..86261ae8 100644 --- a/test/dom/useContext.tsx +++ b/src/dom/__tests__/useContext.test.tsx @@ -1,5 +1,5 @@ import React, { createContext, useContext } from 'react' -import { renderHook } from '../../src/dom' +import { renderHook } from '../index' describe('useContext tests', () => { test('should get default value from context', () => { diff --git a/test/dom/useEffect.ts b/src/dom/__tests__/useEffect.test.ts similarity index 97% rename from test/dom/useEffect.ts rename to src/dom/__tests__/useEffect.test.ts index b09c2fa6..85a72337 100644 --- a/test/dom/useEffect.ts +++ b/src/dom/__tests__/useEffect.test.ts @@ -1,5 +1,5 @@ import { useEffect, useLayoutEffect } from 'react' -import { renderHook } from '../../src/dom' +import { renderHook } from '../index' describe('useEffect tests', () => { test('should handle useEffect hook', () => { diff --git a/test/dom/useMemo.ts b/src/dom/__tests__/useMemo.test.ts similarity index 96% rename from test/dom/useMemo.ts rename to src/dom/__tests__/useMemo.test.ts index f8a7e86a..1db72a01 100644 --- a/test/dom/useMemo.ts +++ b/src/dom/__tests__/useMemo.test.ts @@ -1,5 +1,5 @@ import { useMemo, useCallback } from 'react' -import { renderHook } from '../../src/dom' +import { renderHook } from '../index' describe('useCallback tests', () => { test('should handle useMemo hook', () => { diff --git a/test/dom/useReducer.ts b/src/dom/__tests__/useReducer.test.ts similarity index 91% rename from test/dom/useReducer.ts rename to src/dom/__tests__/useReducer.test.ts index 0e9ff9e8..c3385858 100644 --- a/test/dom/useReducer.ts +++ b/src/dom/__tests__/useReducer.test.ts @@ -1,5 +1,5 @@ import { useReducer } from 'react' -import { renderHook, act } from '../../src/dom' +import { renderHook, act } from '../index' describe('useReducer tests', () => { test('should handle useReducer hook', () => { diff --git a/test/dom/useRef.ts b/src/dom/__tests__/useRef.test.ts similarity index 94% rename from test/dom/useRef.ts rename to src/dom/__tests__/useRef.test.ts index baca0ead..67c9c8c6 100644 --- a/test/dom/useRef.ts +++ b/src/dom/__tests__/useRef.test.ts @@ -1,5 +1,5 @@ import { useRef, useImperativeHandle } from 'react' -import { renderHook } from '../../src/dom' +import { renderHook } from '../index' describe('useHook tests', () => { test('should handle useRef hook', () => { diff --git a/test/dom/useState.ts b/src/dom/__tests__/useState.test.ts similarity index 91% rename from test/dom/useState.ts rename to src/dom/__tests__/useState.test.ts index e25c8bbe..d937c69f 100644 --- a/test/dom/useState.ts +++ b/src/dom/__tests__/useState.test.ts @@ -1,5 +1,5 @@ import { useState } from 'react' -import { renderHook, act } from '../../src/dom' +import { renderHook, act } from '../index' describe('useState tests', () => { test('should use setState value', () => { diff --git a/test/native/asyncHook.ts b/src/native/__tests__/asyncHook.test.ts similarity index 99% rename from test/native/asyncHook.ts rename to src/native/__tests__/asyncHook.test.ts index 18977b19..b9371ed3 100644 --- a/test/native/asyncHook.ts +++ b/src/native/__tests__/asyncHook.test.ts @@ -1,5 +1,5 @@ import { useState, useRef, useEffect } from 'react' -import { renderHook } from '../../src/native' +import { renderHook } from '../index' describe('async hook tests', () => { const useSequence = (...values: string[]) => { diff --git a/test/dom/autoCleanup.disabled.ts b/src/native/__tests__/autoCleanup.disabled.test.ts similarity index 84% rename from test/dom/autoCleanup.disabled.ts rename to src/native/__tests__/autoCleanup.disabled.test.ts index 1bcf45be..3eafbe5a 100644 --- a/test/dom/autoCleanup.disabled.ts +++ b/src/native/__tests__/autoCleanup.disabled.test.ts @@ -1,6 +1,6 @@ import { useEffect } from 'react' -import { ReactHooksRenderer } from 'types/react' +import { ReactHooksRenderer } from '../../types/react' // This verifies that if RHTL_SKIP_AUTO_CLEANUP is set // then we DON'T auto-wire up the afterEach for folks @@ -11,7 +11,7 @@ describe('skip auto cleanup (disabled) tests', () => { beforeAll(() => { process.env.RHTL_SKIP_AUTO_CLEANUP = 'true' // eslint-disable-next-line @typescript-eslint/no-var-requires - renderHook = (require('../../src/dom') as ReactHooksRenderer).renderHook + renderHook = (require('../index') as ReactHooksRenderer).renderHook }) test('first', () => { diff --git a/test/dom/autoCleanup.noAfterEach.ts b/src/native/__tests__/autoCleanup.noAfterEach.test.ts similarity index 86% rename from test/dom/autoCleanup.noAfterEach.ts rename to src/native/__tests__/autoCleanup.noAfterEach.test.ts index 12dd75e1..053cecc5 100644 --- a/test/dom/autoCleanup.noAfterEach.ts +++ b/src/native/__tests__/autoCleanup.noAfterEach.test.ts @@ -1,6 +1,6 @@ import { useEffect } from 'react' -import { ReactHooksRenderer } from 'types/react' +import { ReactHooksRenderer } from '../../types/react' // This verifies that if RHTL_SKIP_AUTO_CLEANUP is set // then we DON'T auto-wire up the afterEach for folks @@ -13,7 +13,7 @@ describe('skip auto cleanup (no afterEach) tests', () => { // eslint-disable-next-line no-global-assign afterEach = false // eslint-disable-next-line @typescript-eslint/no-var-requires - renderHook = (require('../../src/dom') as ReactHooksRenderer).renderHook + renderHook = (require('../index') as ReactHooksRenderer).renderHook }) test('first', () => { diff --git a/test/native/autoCleanup.ts b/src/native/__tests__/autoCleanup.test.ts similarity index 91% rename from test/native/autoCleanup.ts rename to src/native/__tests__/autoCleanup.test.ts index 2d7addf9..dca4ca1e 100644 --- a/test/native/autoCleanup.ts +++ b/src/native/__tests__/autoCleanup.test.ts @@ -1,5 +1,5 @@ import { useEffect } from 'react' -import { renderHook } from '../../src/native' +import { renderHook } from '../index' // This verifies that by importing RHTL in an // environment which supports afterEach (like Jest) diff --git a/test/native/cleanup.ts b/src/native/__tests__/cleanup.test.ts similarity index 99% rename from test/native/cleanup.ts rename to src/native/__tests__/cleanup.test.ts index 9eeed775..20a0f267 100644 --- a/test/native/cleanup.ts +++ b/src/native/__tests__/cleanup.test.ts @@ -1,5 +1,5 @@ import { useEffect } from 'react' -import { renderHook, cleanup, addCleanup, removeCleanup } from '../../src/native/pure' +import { renderHook, cleanup, addCleanup, removeCleanup } from '../pure' describe('cleanup tests', () => { test('should flush effects on cleanup', async () => { diff --git a/test/native/customHook.ts b/src/native/__tests__/customHook.test.ts similarity index 93% rename from test/native/customHook.ts rename to src/native/__tests__/customHook.test.ts index 8d699188..fe617465 100644 --- a/test/native/customHook.ts +++ b/src/native/__tests__/customHook.test.ts @@ -1,5 +1,5 @@ import { useState, useCallback } from 'react' -import { renderHook, act } from '../../src/native' +import { renderHook, act } from '../index' describe('custom hook tests', () => { function useCounter() { diff --git a/test/native/errorHook.ts b/src/native/__tests__/errorHook.test.ts similarity index 98% rename from test/native/errorHook.ts rename to src/native/__tests__/errorHook.test.ts index 078227c7..f2ae6165 100644 --- a/test/native/errorHook.ts +++ b/src/native/__tests__/errorHook.test.ts @@ -1,5 +1,5 @@ import { useState, useEffect } from 'react' -import { renderHook } from '../../src/native' +import { renderHook } from '../index' describe('error hook tests', () => { function useError(throwError?: boolean) { diff --git a/test/native/resultHistory.ts b/src/native/__tests__/resultHistory.test.ts similarity index 94% rename from test/native/resultHistory.ts rename to src/native/__tests__/resultHistory.test.ts index db01d5b7..1d56f33d 100644 --- a/test/native/resultHistory.ts +++ b/src/native/__tests__/resultHistory.test.ts @@ -1,4 +1,4 @@ -import { renderHook } from '../../src/native' +import { renderHook } from '../index' describe('result history tests', () => { let count = 0 diff --git a/test/native/suspenseHook.ts b/src/native/__tests__/suspenseHook.test.ts similarity index 96% rename from test/native/suspenseHook.ts rename to src/native/__tests__/suspenseHook.test.ts index 76e49830..030661db 100644 --- a/test/native/suspenseHook.ts +++ b/src/native/__tests__/suspenseHook.test.ts @@ -1,4 +1,4 @@ -import { renderHook } from '../../src/native' +import { renderHook } from '../index' describe('suspense hook tests', () => { const cache: { value?: Promise | string | Error } = {} diff --git a/test/native/useContext.tsx b/src/native/__tests__/useContext.test.tsx similarity index 97% rename from test/native/useContext.tsx rename to src/native/__tests__/useContext.test.tsx index c306fb21..86261ae8 100644 --- a/test/native/useContext.tsx +++ b/src/native/__tests__/useContext.test.tsx @@ -1,5 +1,5 @@ import React, { createContext, useContext } from 'react' -import { renderHook } from '../../src/native' +import { renderHook } from '../index' describe('useContext tests', () => { test('should get default value from context', () => { diff --git a/test/native/useEffect.ts b/src/native/__tests__/useEffect.test.ts similarity index 96% rename from test/native/useEffect.ts rename to src/native/__tests__/useEffect.test.ts index c9c4a8d9..85a72337 100644 --- a/test/native/useEffect.ts +++ b/src/native/__tests__/useEffect.test.ts @@ -1,5 +1,5 @@ import { useEffect, useLayoutEffect } from 'react' -import { renderHook } from '../../src/native' +import { renderHook } from '../index' describe('useEffect tests', () => { test('should handle useEffect hook', () => { diff --git a/test/native/useMemo.ts b/src/native/__tests__/useMemo.test.ts similarity index 96% rename from test/native/useMemo.ts rename to src/native/__tests__/useMemo.test.ts index 465ef591..1db72a01 100644 --- a/test/native/useMemo.ts +++ b/src/native/__tests__/useMemo.test.ts @@ -1,5 +1,5 @@ import { useMemo, useCallback } from 'react' -import { renderHook } from '../../src/native' +import { renderHook } from '../index' describe('useCallback tests', () => { test('should handle useMemo hook', () => { diff --git a/test/native/useReducer.ts b/src/native/__tests__/useReducer.test.ts similarity index 90% rename from test/native/useReducer.ts rename to src/native/__tests__/useReducer.test.ts index 2de8c44d..c3385858 100644 --- a/test/native/useReducer.ts +++ b/src/native/__tests__/useReducer.test.ts @@ -1,5 +1,5 @@ import { useReducer } from 'react' -import { renderHook, act } from '../../src/native' +import { renderHook, act } from '../index' describe('useReducer tests', () => { test('should handle useReducer hook', () => { diff --git a/test/native/useRef.ts b/src/native/__tests__/useRef.test.ts similarity index 94% rename from test/native/useRef.ts rename to src/native/__tests__/useRef.test.ts index a1ca0e27..67c9c8c6 100644 --- a/test/native/useRef.ts +++ b/src/native/__tests__/useRef.test.ts @@ -1,5 +1,5 @@ import { useRef, useImperativeHandle } from 'react' -import { renderHook } from '../../src/native' +import { renderHook } from '../index' describe('useHook tests', () => { test('should handle useRef hook', () => { diff --git a/test/native/useState.ts b/src/native/__tests__/useState.test.ts similarity index 91% rename from test/native/useState.ts rename to src/native/__tests__/useState.test.ts index f384434f..d937c69f 100644 --- a/test/native/useState.ts +++ b/src/native/__tests__/useState.test.ts @@ -1,5 +1,5 @@ import { useState } from 'react' -import { renderHook, act } from '../../src/native' +import { renderHook, act } from '../index' describe('useState tests', () => { test('should use setState value', () => { diff --git a/test/server/asyncHook.ts b/src/server/__tests__/asyncHook.test.ts similarity index 99% rename from test/server/asyncHook.ts rename to src/server/__tests__/asyncHook.test.ts index 9c872430..7b228fb0 100644 --- a/test/server/asyncHook.ts +++ b/src/server/__tests__/asyncHook.test.ts @@ -1,6 +1,6 @@ import { useState, useRef, useEffect } from 'react' -import { renderHook } from '../../src/server' +import { renderHook } from '../index' describe('async hook tests', () => { const useSequence = (...values: string[]) => { diff --git a/test/server/autoCleanup.disabled.ts b/src/server/__tests__/autoCleanup.disabled.test.ts similarity index 84% rename from test/server/autoCleanup.disabled.ts rename to src/server/__tests__/autoCleanup.disabled.test.ts index 00853a13..3eafbe5a 100644 --- a/test/server/autoCleanup.disabled.ts +++ b/src/server/__tests__/autoCleanup.disabled.test.ts @@ -1,6 +1,6 @@ import { useEffect } from 'react' -import { ReactHooksRenderer } from 'types' +import { ReactHooksRenderer } from '../../types/react' // This verifies that if RHTL_SKIP_AUTO_CLEANUP is set // then we DON'T auto-wire up the afterEach for folks @@ -11,7 +11,7 @@ describe('skip auto cleanup (disabled) tests', () => { beforeAll(() => { process.env.RHTL_SKIP_AUTO_CLEANUP = 'true' // eslint-disable-next-line @typescript-eslint/no-var-requires - renderHook = (require('../../src/server') as ReactHooksRenderer).renderHook + renderHook = (require('../index') as ReactHooksRenderer).renderHook }) test('first', () => { diff --git a/test/native/autoCleanup.noAfterEach.ts b/src/server/__tests__/autoCleanup.noAfterEach.test.ts similarity index 86% rename from test/native/autoCleanup.noAfterEach.ts rename to src/server/__tests__/autoCleanup.noAfterEach.test.ts index 49b00b3d..053cecc5 100644 --- a/test/native/autoCleanup.noAfterEach.ts +++ b/src/server/__tests__/autoCleanup.noAfterEach.test.ts @@ -1,6 +1,6 @@ import { useEffect } from 'react' -import { ReactHooksRenderer } from 'types' +import { ReactHooksRenderer } from '../../types/react' // This verifies that if RHTL_SKIP_AUTO_CLEANUP is set // then we DON'T auto-wire up the afterEach for folks @@ -13,7 +13,7 @@ describe('skip auto cleanup (no afterEach) tests', () => { // eslint-disable-next-line no-global-assign afterEach = false // eslint-disable-next-line @typescript-eslint/no-var-requires - renderHook = (require('../../src/native') as ReactHooksRenderer).renderHook + renderHook = (require('../index') as ReactHooksRenderer).renderHook }) test('first', () => { diff --git a/test/server/autoCleanup.ts b/src/server/__tests__/autoCleanup.test.ts similarity index 94% rename from test/server/autoCleanup.ts rename to src/server/__tests__/autoCleanup.test.ts index 087c2af8..2e04218a 100644 --- a/test/server/autoCleanup.ts +++ b/src/server/__tests__/autoCleanup.test.ts @@ -1,5 +1,5 @@ import { useEffect } from 'react' -import { renderHook } from '../../src/server' +import { renderHook } from '../index' // This verifies that by importing RHTL in an // environment which supports afterEach (like Jest) diff --git a/test/server/cleanup.ts b/src/server/__tests__/cleanup.test.ts similarity index 96% rename from test/server/cleanup.ts rename to src/server/__tests__/cleanup.test.ts index e8033492..d6590260 100644 --- a/test/server/cleanup.ts +++ b/src/server/__tests__/cleanup.test.ts @@ -1,5 +1,5 @@ import { useEffect } from 'react' -import { renderHook, cleanup } from '../../src/server' +import { renderHook, cleanup } from '../index' describe('cleanup tests', () => { test('should flush effects on cleanup', async () => { diff --git a/test/server/customHook.ts b/src/server/__tests__/customHook.test.ts similarity index 93% rename from test/server/customHook.ts rename to src/server/__tests__/customHook.test.ts index 2fadd2d6..23e11db0 100644 --- a/test/server/customHook.ts +++ b/src/server/__tests__/customHook.test.ts @@ -1,5 +1,5 @@ import { useState, useCallback } from 'react' -import { renderHook, act } from '../../src/server' +import { renderHook, act } from '../index' describe('custom hook tests', () => { function useCounter() { diff --git a/test/server/errorHook.ts b/src/server/__tests__/errorHook.test.ts similarity index 98% rename from test/server/errorHook.ts rename to src/server/__tests__/errorHook.test.ts index 1fcbd34b..e7fc7f4c 100644 --- a/test/server/errorHook.ts +++ b/src/server/__tests__/errorHook.test.ts @@ -1,6 +1,6 @@ import { useState, useEffect } from 'react' -import { renderHook } from '../../src/server' +import { renderHook } from '../index' describe('error hook tests', () => { function useError(throwError?: boolean) { diff --git a/test/server/hydrationErrors.ts b/src/server/__tests__/hydrationErrors.test.ts similarity index 94% rename from test/server/hydrationErrors.ts rename to src/server/__tests__/hydrationErrors.test.ts index 4b14dd0a..21774c96 100644 --- a/test/server/hydrationErrors.ts +++ b/src/server/__tests__/hydrationErrors.test.ts @@ -1,5 +1,5 @@ import { useState, useCallback } from 'react' -import { renderHook } from '../../src/server' +import { renderHook } from '../index' describe('hydration errors tests', () => { function useCounter() { diff --git a/test/server/useContext.tsx b/src/server/__tests__/useContext.test.tsx similarity index 96% rename from test/server/useContext.tsx rename to src/server/__tests__/useContext.test.tsx index 33c1008b..3dd84048 100644 --- a/test/server/useContext.tsx +++ b/src/server/__tests__/useContext.test.tsx @@ -1,5 +1,5 @@ import React, { createContext, useContext } from 'react' -import { renderHook } from '../../src/server' +import { renderHook } from '../index' describe('useContext tests', () => { test('should get default value from context', () => { diff --git a/test/server/useEffect.ts b/src/server/__tests__/useEffect.test.ts similarity index 94% rename from test/server/useEffect.ts rename to src/server/__tests__/useEffect.test.ts index 1adf23e4..b036f299 100644 --- a/test/server/useEffect.ts +++ b/src/server/__tests__/useEffect.test.ts @@ -1,5 +1,5 @@ import { useEffect } from 'react' -import { renderHook } from '../../src/server' +import { renderHook } from '../index' describe('useEffect tests', () => { test('should handle useEffect hook', () => { diff --git a/test/server/useMemo.ts b/src/server/__tests__/useMemo.test.ts similarity index 97% rename from test/server/useMemo.ts rename to src/server/__tests__/useMemo.test.ts index 202db24c..c633b67b 100644 --- a/test/server/useMemo.ts +++ b/src/server/__tests__/useMemo.test.ts @@ -1,5 +1,5 @@ import { useMemo, useCallback } from 'react' -import { renderHook } from '../../src/server' +import { renderHook } from '../index' describe('useCallback tests', () => { test('should handle useMemo hook', () => { diff --git a/test/server/useReducer.ts b/src/server/__tests__/useReducer.test.ts similarity index 91% rename from test/server/useReducer.ts rename to src/server/__tests__/useReducer.test.ts index f11daf50..62883529 100644 --- a/test/server/useReducer.ts +++ b/src/server/__tests__/useReducer.test.ts @@ -1,5 +1,5 @@ import { useReducer } from 'react' -import { renderHook, act } from '../../src/server' +import { renderHook, act } from '../index' describe('useReducer tests', () => { test('should handle useReducer hook', () => { diff --git a/test/server/useRef.ts b/src/server/__tests__/useRef.test.ts similarity index 94% rename from test/server/useRef.ts rename to src/server/__tests__/useRef.test.ts index 26cdc323..1e4856c9 100644 --- a/test/server/useRef.ts +++ b/src/server/__tests__/useRef.test.ts @@ -1,5 +1,5 @@ import { useRef, useImperativeHandle } from 'react' -import { renderHook } from '../../src/server' +import { renderHook } from '../index' describe('useHook tests', () => { test('should handle useRef hook', () => { diff --git a/test/server/useState.ts b/src/server/__tests__/useState.test.ts similarity index 94% rename from test/server/useState.ts rename to src/server/__tests__/useState.test.ts index b3546357..fe24153c 100644 --- a/test/server/useState.ts +++ b/src/server/__tests__/useState.test.ts @@ -1,5 +1,5 @@ import { useState } from 'react' -import { renderHook, act } from '../../src/server' +import { renderHook, act } from '../index' describe('useState tests', () => { test('should use state value', () => { diff --git a/tsconfig.json b/tsconfig.json index 2b5e3606..778dad00 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,5 +3,6 @@ "compilerOptions": { "allowJs": true, "target": "ES6" - } + }, + "exclude": ["**/__tests__/*"] } From 62f05ba7e1ab06a872c7f4ccf70b13472a5b2ffb Mon Sep 17 00:00:00 2001 From: Michael Peyper Date: Sun, 10 Jan 2021 20:46:15 +1100 Subject: [PATCH 2/3] chore(config): update outdated configs after test changes --- .eslintrc | 2 +- jest.config.js | 7 ------- src/__tests__/tsconfig.json | 8 -------- tsconfig.json | 4 +--- 4 files changed, 2 insertions(+), 19 deletions(-) delete mode 100644 jest.config.js delete mode 100644 src/__tests__/tsconfig.json diff --git a/.eslintrc b/.eslintrc index 5e90a5cf..f49a9cab 100644 --- a/.eslintrc +++ b/.eslintrc @@ -11,6 +11,6 @@ "@typescript-eslint/no-invalid-void-type": "off" }, "parserOptions": { - "project": ["./tsconfig.json", "./test/tsconfig.json", "./scripts/tsconfig.json"] + "project": ["./tsconfig.json", "./scripts/tsconfig.json"] } } diff --git a/jest.config.js b/jest.config.js deleted file mode 100644 index 588591dd..00000000 --- a/jest.config.js +++ /dev/null @@ -1,7 +0,0 @@ -// eslint-disable-next-line -const { jest: jestConfig } = require('kcd-scripts/config') - -module.exports = Object.assign(jestConfig, { - roots: ['/src'], - testMatch: ['/**/__tests__/*.(ts|tsx|js)'] -}) diff --git a/src/__tests__/tsconfig.json b/src/__tests__/tsconfig.json deleted file mode 100644 index 96b00ced..00000000 --- a/src/__tests__/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../../tsconfig", - "compilerOptions": { - "declaration": false - }, - "exclude": [], - "include": ["**/*.test.(ts|tsx)"] -} diff --git a/tsconfig.json b/tsconfig.json index 778dad00..7661340c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,6 @@ { "extends": "./node_modules/kcd-scripts/shared-tsconfig.json", "compilerOptions": { - "allowJs": true, "target": "ES6" - }, - "exclude": ["**/__tests__/*"] + } } From a86fd960db5e9356ec9af2eba3e21ab3edd39015 Mon Sep 17 00:00:00 2001 From: Michael Peyper Date: Sun, 10 Jan 2021 20:59:57 +1100 Subject: [PATCH 3/3] refactor: remove index from import paths in tests --- src/dom/__tests__/asyncHook.test.ts | 2 +- src/dom/__tests__/autoCleanup.disabled.test.ts | 2 +- src/dom/__tests__/autoCleanup.noAfterEach.test.ts | 2 +- src/dom/__tests__/autoCleanup.test.ts | 2 +- src/dom/__tests__/customHook.test.ts | 2 +- src/dom/__tests__/errorHook.test.ts | 2 +- src/dom/__tests__/resultHistory.test.ts | 2 +- src/dom/__tests__/suspenseHook.test.ts | 2 +- src/dom/__tests__/useContext.test.tsx | 2 +- src/dom/__tests__/useEffect.test.ts | 2 +- src/dom/__tests__/useMemo.test.ts | 2 +- src/dom/__tests__/useReducer.test.ts | 2 +- src/dom/__tests__/useRef.test.ts | 2 +- src/dom/__tests__/useState.test.ts | 2 +- src/native/__tests__/asyncHook.test.ts | 2 +- src/native/__tests__/autoCleanup.disabled.test.ts | 2 +- src/native/__tests__/autoCleanup.noAfterEach.test.ts | 2 +- src/native/__tests__/autoCleanup.test.ts | 2 +- src/native/__tests__/customHook.test.ts | 2 +- src/native/__tests__/errorHook.test.ts | 2 +- src/native/__tests__/resultHistory.test.ts | 2 +- src/native/__tests__/suspenseHook.test.ts | 2 +- src/native/__tests__/useContext.test.tsx | 2 +- src/native/__tests__/useEffect.test.ts | 2 +- src/native/__tests__/useMemo.test.ts | 2 +- src/native/__tests__/useReducer.test.ts | 2 +- src/native/__tests__/useRef.test.ts | 2 +- src/native/__tests__/useState.test.ts | 2 +- src/server/__tests__/asyncHook.test.ts | 2 +- src/server/__tests__/autoCleanup.disabled.test.ts | 2 +- src/server/__tests__/autoCleanup.noAfterEach.test.ts | 2 +- src/server/__tests__/autoCleanup.test.ts | 2 +- src/server/__tests__/cleanup.test.ts | 2 +- src/server/__tests__/customHook.test.ts | 2 +- src/server/__tests__/errorHook.test.ts | 2 +- src/server/__tests__/hydrationErrors.test.ts | 2 +- src/server/__tests__/useContext.test.tsx | 2 +- src/server/__tests__/useEffect.test.ts | 2 +- src/server/__tests__/useMemo.test.ts | 2 +- src/server/__tests__/useReducer.test.ts | 2 +- src/server/__tests__/useRef.test.ts | 2 +- src/server/__tests__/useState.test.ts | 2 +- 42 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/dom/__tests__/asyncHook.test.ts b/src/dom/__tests__/asyncHook.test.ts index b9371ed3..4484b81e 100644 --- a/src/dom/__tests__/asyncHook.test.ts +++ b/src/dom/__tests__/asyncHook.test.ts @@ -1,5 +1,5 @@ import { useState, useRef, useEffect } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' describe('async hook tests', () => { const useSequence = (...values: string[]) => { diff --git a/src/dom/__tests__/autoCleanup.disabled.test.ts b/src/dom/__tests__/autoCleanup.disabled.test.ts index 3eafbe5a..1485ff47 100644 --- a/src/dom/__tests__/autoCleanup.disabled.test.ts +++ b/src/dom/__tests__/autoCleanup.disabled.test.ts @@ -11,7 +11,7 @@ describe('skip auto cleanup (disabled) tests', () => { beforeAll(() => { process.env.RHTL_SKIP_AUTO_CLEANUP = 'true' // eslint-disable-next-line @typescript-eslint/no-var-requires - renderHook = (require('../index') as ReactHooksRenderer).renderHook + renderHook = (require('..') as ReactHooksRenderer).renderHook }) test('first', () => { diff --git a/src/dom/__tests__/autoCleanup.noAfterEach.test.ts b/src/dom/__tests__/autoCleanup.noAfterEach.test.ts index 053cecc5..afe4514d 100644 --- a/src/dom/__tests__/autoCleanup.noAfterEach.test.ts +++ b/src/dom/__tests__/autoCleanup.noAfterEach.test.ts @@ -13,7 +13,7 @@ describe('skip auto cleanup (no afterEach) tests', () => { // eslint-disable-next-line no-global-assign afterEach = false // eslint-disable-next-line @typescript-eslint/no-var-requires - renderHook = (require('../index') as ReactHooksRenderer).renderHook + renderHook = (require('..') as ReactHooksRenderer).renderHook }) test('first', () => { diff --git a/src/dom/__tests__/autoCleanup.test.ts b/src/dom/__tests__/autoCleanup.test.ts index dca4ca1e..f783f1c2 100644 --- a/src/dom/__tests__/autoCleanup.test.ts +++ b/src/dom/__tests__/autoCleanup.test.ts @@ -1,5 +1,5 @@ import { useEffect } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' // This verifies that by importing RHTL in an // environment which supports afterEach (like Jest) diff --git a/src/dom/__tests__/customHook.test.ts b/src/dom/__tests__/customHook.test.ts index fe617465..5a1e83ab 100644 --- a/src/dom/__tests__/customHook.test.ts +++ b/src/dom/__tests__/customHook.test.ts @@ -1,5 +1,5 @@ import { useState, useCallback } from 'react' -import { renderHook, act } from '../index' +import { renderHook, act } from '..' describe('custom hook tests', () => { function useCounter() { diff --git a/src/dom/__tests__/errorHook.test.ts b/src/dom/__tests__/errorHook.test.ts index f2ae6165..7fb7a265 100644 --- a/src/dom/__tests__/errorHook.test.ts +++ b/src/dom/__tests__/errorHook.test.ts @@ -1,5 +1,5 @@ import { useState, useEffect } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' describe('error hook tests', () => { function useError(throwError?: boolean) { diff --git a/src/dom/__tests__/resultHistory.test.ts b/src/dom/__tests__/resultHistory.test.ts index 1d56f33d..1da5e94b 100644 --- a/src/dom/__tests__/resultHistory.test.ts +++ b/src/dom/__tests__/resultHistory.test.ts @@ -1,4 +1,4 @@ -import { renderHook } from '../index' +import { renderHook } from '..' describe('result history tests', () => { let count = 0 diff --git a/src/dom/__tests__/suspenseHook.test.ts b/src/dom/__tests__/suspenseHook.test.ts index 030661db..d3f19a1d 100644 --- a/src/dom/__tests__/suspenseHook.test.ts +++ b/src/dom/__tests__/suspenseHook.test.ts @@ -1,4 +1,4 @@ -import { renderHook } from '../index' +import { renderHook } from '..' describe('suspense hook tests', () => { const cache: { value?: Promise | string | Error } = {} diff --git a/src/dom/__tests__/useContext.test.tsx b/src/dom/__tests__/useContext.test.tsx index 86261ae8..84046e30 100644 --- a/src/dom/__tests__/useContext.test.tsx +++ b/src/dom/__tests__/useContext.test.tsx @@ -1,5 +1,5 @@ import React, { createContext, useContext } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' describe('useContext tests', () => { test('should get default value from context', () => { diff --git a/src/dom/__tests__/useEffect.test.ts b/src/dom/__tests__/useEffect.test.ts index 85a72337..0091b7a8 100644 --- a/src/dom/__tests__/useEffect.test.ts +++ b/src/dom/__tests__/useEffect.test.ts @@ -1,5 +1,5 @@ import { useEffect, useLayoutEffect } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' describe('useEffect tests', () => { test('should handle useEffect hook', () => { diff --git a/src/dom/__tests__/useMemo.test.ts b/src/dom/__tests__/useMemo.test.ts index 1db72a01..dcf0de7d 100644 --- a/src/dom/__tests__/useMemo.test.ts +++ b/src/dom/__tests__/useMemo.test.ts @@ -1,5 +1,5 @@ import { useMemo, useCallback } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' describe('useCallback tests', () => { test('should handle useMemo hook', () => { diff --git a/src/dom/__tests__/useReducer.test.ts b/src/dom/__tests__/useReducer.test.ts index c3385858..fab39201 100644 --- a/src/dom/__tests__/useReducer.test.ts +++ b/src/dom/__tests__/useReducer.test.ts @@ -1,5 +1,5 @@ import { useReducer } from 'react' -import { renderHook, act } from '../index' +import { renderHook, act } from '..' describe('useReducer tests', () => { test('should handle useReducer hook', () => { diff --git a/src/dom/__tests__/useRef.test.ts b/src/dom/__tests__/useRef.test.ts index 67c9c8c6..a8663e16 100644 --- a/src/dom/__tests__/useRef.test.ts +++ b/src/dom/__tests__/useRef.test.ts @@ -1,5 +1,5 @@ import { useRef, useImperativeHandle } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' describe('useHook tests', () => { test('should handle useRef hook', () => { diff --git a/src/dom/__tests__/useState.test.ts b/src/dom/__tests__/useState.test.ts index d937c69f..78cbaa6f 100644 --- a/src/dom/__tests__/useState.test.ts +++ b/src/dom/__tests__/useState.test.ts @@ -1,5 +1,5 @@ import { useState } from 'react' -import { renderHook, act } from '../index' +import { renderHook, act } from '..' describe('useState tests', () => { test('should use setState value', () => { diff --git a/src/native/__tests__/asyncHook.test.ts b/src/native/__tests__/asyncHook.test.ts index b9371ed3..4484b81e 100644 --- a/src/native/__tests__/asyncHook.test.ts +++ b/src/native/__tests__/asyncHook.test.ts @@ -1,5 +1,5 @@ import { useState, useRef, useEffect } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' describe('async hook tests', () => { const useSequence = (...values: string[]) => { diff --git a/src/native/__tests__/autoCleanup.disabled.test.ts b/src/native/__tests__/autoCleanup.disabled.test.ts index 3eafbe5a..1485ff47 100644 --- a/src/native/__tests__/autoCleanup.disabled.test.ts +++ b/src/native/__tests__/autoCleanup.disabled.test.ts @@ -11,7 +11,7 @@ describe('skip auto cleanup (disabled) tests', () => { beforeAll(() => { process.env.RHTL_SKIP_AUTO_CLEANUP = 'true' // eslint-disable-next-line @typescript-eslint/no-var-requires - renderHook = (require('../index') as ReactHooksRenderer).renderHook + renderHook = (require('..') as ReactHooksRenderer).renderHook }) test('first', () => { diff --git a/src/native/__tests__/autoCleanup.noAfterEach.test.ts b/src/native/__tests__/autoCleanup.noAfterEach.test.ts index 053cecc5..afe4514d 100644 --- a/src/native/__tests__/autoCleanup.noAfterEach.test.ts +++ b/src/native/__tests__/autoCleanup.noAfterEach.test.ts @@ -13,7 +13,7 @@ describe('skip auto cleanup (no afterEach) tests', () => { // eslint-disable-next-line no-global-assign afterEach = false // eslint-disable-next-line @typescript-eslint/no-var-requires - renderHook = (require('../index') as ReactHooksRenderer).renderHook + renderHook = (require('..') as ReactHooksRenderer).renderHook }) test('first', () => { diff --git a/src/native/__tests__/autoCleanup.test.ts b/src/native/__tests__/autoCleanup.test.ts index dca4ca1e..f783f1c2 100644 --- a/src/native/__tests__/autoCleanup.test.ts +++ b/src/native/__tests__/autoCleanup.test.ts @@ -1,5 +1,5 @@ import { useEffect } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' // This verifies that by importing RHTL in an // environment which supports afterEach (like Jest) diff --git a/src/native/__tests__/customHook.test.ts b/src/native/__tests__/customHook.test.ts index fe617465..5a1e83ab 100644 --- a/src/native/__tests__/customHook.test.ts +++ b/src/native/__tests__/customHook.test.ts @@ -1,5 +1,5 @@ import { useState, useCallback } from 'react' -import { renderHook, act } from '../index' +import { renderHook, act } from '..' describe('custom hook tests', () => { function useCounter() { diff --git a/src/native/__tests__/errorHook.test.ts b/src/native/__tests__/errorHook.test.ts index f2ae6165..7fb7a265 100644 --- a/src/native/__tests__/errorHook.test.ts +++ b/src/native/__tests__/errorHook.test.ts @@ -1,5 +1,5 @@ import { useState, useEffect } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' describe('error hook tests', () => { function useError(throwError?: boolean) { diff --git a/src/native/__tests__/resultHistory.test.ts b/src/native/__tests__/resultHistory.test.ts index 1d56f33d..1da5e94b 100644 --- a/src/native/__tests__/resultHistory.test.ts +++ b/src/native/__tests__/resultHistory.test.ts @@ -1,4 +1,4 @@ -import { renderHook } from '../index' +import { renderHook } from '..' describe('result history tests', () => { let count = 0 diff --git a/src/native/__tests__/suspenseHook.test.ts b/src/native/__tests__/suspenseHook.test.ts index 030661db..d3f19a1d 100644 --- a/src/native/__tests__/suspenseHook.test.ts +++ b/src/native/__tests__/suspenseHook.test.ts @@ -1,4 +1,4 @@ -import { renderHook } from '../index' +import { renderHook } from '..' describe('suspense hook tests', () => { const cache: { value?: Promise | string | Error } = {} diff --git a/src/native/__tests__/useContext.test.tsx b/src/native/__tests__/useContext.test.tsx index 86261ae8..84046e30 100644 --- a/src/native/__tests__/useContext.test.tsx +++ b/src/native/__tests__/useContext.test.tsx @@ -1,5 +1,5 @@ import React, { createContext, useContext } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' describe('useContext tests', () => { test('should get default value from context', () => { diff --git a/src/native/__tests__/useEffect.test.ts b/src/native/__tests__/useEffect.test.ts index 85a72337..0091b7a8 100644 --- a/src/native/__tests__/useEffect.test.ts +++ b/src/native/__tests__/useEffect.test.ts @@ -1,5 +1,5 @@ import { useEffect, useLayoutEffect } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' describe('useEffect tests', () => { test('should handle useEffect hook', () => { diff --git a/src/native/__tests__/useMemo.test.ts b/src/native/__tests__/useMemo.test.ts index 1db72a01..dcf0de7d 100644 --- a/src/native/__tests__/useMemo.test.ts +++ b/src/native/__tests__/useMemo.test.ts @@ -1,5 +1,5 @@ import { useMemo, useCallback } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' describe('useCallback tests', () => { test('should handle useMemo hook', () => { diff --git a/src/native/__tests__/useReducer.test.ts b/src/native/__tests__/useReducer.test.ts index c3385858..fab39201 100644 --- a/src/native/__tests__/useReducer.test.ts +++ b/src/native/__tests__/useReducer.test.ts @@ -1,5 +1,5 @@ import { useReducer } from 'react' -import { renderHook, act } from '../index' +import { renderHook, act } from '..' describe('useReducer tests', () => { test('should handle useReducer hook', () => { diff --git a/src/native/__tests__/useRef.test.ts b/src/native/__tests__/useRef.test.ts index 67c9c8c6..a8663e16 100644 --- a/src/native/__tests__/useRef.test.ts +++ b/src/native/__tests__/useRef.test.ts @@ -1,5 +1,5 @@ import { useRef, useImperativeHandle } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' describe('useHook tests', () => { test('should handle useRef hook', () => { diff --git a/src/native/__tests__/useState.test.ts b/src/native/__tests__/useState.test.ts index d937c69f..78cbaa6f 100644 --- a/src/native/__tests__/useState.test.ts +++ b/src/native/__tests__/useState.test.ts @@ -1,5 +1,5 @@ import { useState } from 'react' -import { renderHook, act } from '../index' +import { renderHook, act } from '..' describe('useState tests', () => { test('should use setState value', () => { diff --git a/src/server/__tests__/asyncHook.test.ts b/src/server/__tests__/asyncHook.test.ts index 7b228fb0..09ae1871 100644 --- a/src/server/__tests__/asyncHook.test.ts +++ b/src/server/__tests__/asyncHook.test.ts @@ -1,6 +1,6 @@ import { useState, useRef, useEffect } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' describe('async hook tests', () => { const useSequence = (...values: string[]) => { diff --git a/src/server/__tests__/autoCleanup.disabled.test.ts b/src/server/__tests__/autoCleanup.disabled.test.ts index 3eafbe5a..1485ff47 100644 --- a/src/server/__tests__/autoCleanup.disabled.test.ts +++ b/src/server/__tests__/autoCleanup.disabled.test.ts @@ -11,7 +11,7 @@ describe('skip auto cleanup (disabled) tests', () => { beforeAll(() => { process.env.RHTL_SKIP_AUTO_CLEANUP = 'true' // eslint-disable-next-line @typescript-eslint/no-var-requires - renderHook = (require('../index') as ReactHooksRenderer).renderHook + renderHook = (require('..') as ReactHooksRenderer).renderHook }) test('first', () => { diff --git a/src/server/__tests__/autoCleanup.noAfterEach.test.ts b/src/server/__tests__/autoCleanup.noAfterEach.test.ts index 053cecc5..afe4514d 100644 --- a/src/server/__tests__/autoCleanup.noAfterEach.test.ts +++ b/src/server/__tests__/autoCleanup.noAfterEach.test.ts @@ -13,7 +13,7 @@ describe('skip auto cleanup (no afterEach) tests', () => { // eslint-disable-next-line no-global-assign afterEach = false // eslint-disable-next-line @typescript-eslint/no-var-requires - renderHook = (require('../index') as ReactHooksRenderer).renderHook + renderHook = (require('..') as ReactHooksRenderer).renderHook }) test('first', () => { diff --git a/src/server/__tests__/autoCleanup.test.ts b/src/server/__tests__/autoCleanup.test.ts index 2e04218a..87e473c1 100644 --- a/src/server/__tests__/autoCleanup.test.ts +++ b/src/server/__tests__/autoCleanup.test.ts @@ -1,5 +1,5 @@ import { useEffect } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' // This verifies that by importing RHTL in an // environment which supports afterEach (like Jest) diff --git a/src/server/__tests__/cleanup.test.ts b/src/server/__tests__/cleanup.test.ts index d6590260..c12815ac 100644 --- a/src/server/__tests__/cleanup.test.ts +++ b/src/server/__tests__/cleanup.test.ts @@ -1,5 +1,5 @@ import { useEffect } from 'react' -import { renderHook, cleanup } from '../index' +import { renderHook, cleanup } from '..' describe('cleanup tests', () => { test('should flush effects on cleanup', async () => { diff --git a/src/server/__tests__/customHook.test.ts b/src/server/__tests__/customHook.test.ts index 23e11db0..cb512682 100644 --- a/src/server/__tests__/customHook.test.ts +++ b/src/server/__tests__/customHook.test.ts @@ -1,5 +1,5 @@ import { useState, useCallback } from 'react' -import { renderHook, act } from '../index' +import { renderHook, act } from '..' describe('custom hook tests', () => { function useCounter() { diff --git a/src/server/__tests__/errorHook.test.ts b/src/server/__tests__/errorHook.test.ts index e7fc7f4c..10a489ab 100644 --- a/src/server/__tests__/errorHook.test.ts +++ b/src/server/__tests__/errorHook.test.ts @@ -1,6 +1,6 @@ import { useState, useEffect } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' describe('error hook tests', () => { function useError(throwError?: boolean) { diff --git a/src/server/__tests__/hydrationErrors.test.ts b/src/server/__tests__/hydrationErrors.test.ts index 21774c96..56a11aea 100644 --- a/src/server/__tests__/hydrationErrors.test.ts +++ b/src/server/__tests__/hydrationErrors.test.ts @@ -1,5 +1,5 @@ import { useState, useCallback } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' describe('hydration errors tests', () => { function useCounter() { diff --git a/src/server/__tests__/useContext.test.tsx b/src/server/__tests__/useContext.test.tsx index 3dd84048..cf92aab4 100644 --- a/src/server/__tests__/useContext.test.tsx +++ b/src/server/__tests__/useContext.test.tsx @@ -1,5 +1,5 @@ import React, { createContext, useContext } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' describe('useContext tests', () => { test('should get default value from context', () => { diff --git a/src/server/__tests__/useEffect.test.ts b/src/server/__tests__/useEffect.test.ts index b036f299..782b7a03 100644 --- a/src/server/__tests__/useEffect.test.ts +++ b/src/server/__tests__/useEffect.test.ts @@ -1,5 +1,5 @@ import { useEffect } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' describe('useEffect tests', () => { test('should handle useEffect hook', () => { diff --git a/src/server/__tests__/useMemo.test.ts b/src/server/__tests__/useMemo.test.ts index c633b67b..d762cf6a 100644 --- a/src/server/__tests__/useMemo.test.ts +++ b/src/server/__tests__/useMemo.test.ts @@ -1,5 +1,5 @@ import { useMemo, useCallback } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' describe('useCallback tests', () => { test('should handle useMemo hook', () => { diff --git a/src/server/__tests__/useReducer.test.ts b/src/server/__tests__/useReducer.test.ts index 62883529..6184094a 100644 --- a/src/server/__tests__/useReducer.test.ts +++ b/src/server/__tests__/useReducer.test.ts @@ -1,5 +1,5 @@ import { useReducer } from 'react' -import { renderHook, act } from '../index' +import { renderHook, act } from '..' describe('useReducer tests', () => { test('should handle useReducer hook', () => { diff --git a/src/server/__tests__/useRef.test.ts b/src/server/__tests__/useRef.test.ts index 1e4856c9..f30d0bd7 100644 --- a/src/server/__tests__/useRef.test.ts +++ b/src/server/__tests__/useRef.test.ts @@ -1,5 +1,5 @@ import { useRef, useImperativeHandle } from 'react' -import { renderHook } from '../index' +import { renderHook } from '..' describe('useHook tests', () => { test('should handle useRef hook', () => { diff --git a/src/server/__tests__/useState.test.ts b/src/server/__tests__/useState.test.ts index fe24153c..27925863 100644 --- a/src/server/__tests__/useState.test.ts +++ b/src/server/__tests__/useState.test.ts @@ -1,5 +1,5 @@ import { useState } from 'react' -import { renderHook, act } from '../index' +import { renderHook, act } from '..' describe('useState tests', () => { test('should use state value', () => {