Skip to content

Commit 43891e1

Browse files
joshuaellismpeyper
andauthored
refactor: move tests to specifically related folders
* refactor: move tests to specifically related folders * chore(config): update outdated configs after test changes * refactor: remove index from import paths in tests Co-authored-by: Michael Peyper <[email protected]>
1 parent ca32bce commit 43891e1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+62
-68
lines changed

Diff for: .eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"@typescript-eslint/no-invalid-void-type": "off"
1212
},
1313
"parserOptions": {
14-
"project": ["./tsconfig.json", "./test/tsconfig.json", "./scripts/tsconfig.json"]
14+
"project": ["./tsconfig.json", "./scripts/tsconfig.json"]
1515
}
1616
}

Diff for: .gitignore

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1+
# node
12
node_modules
2-
coverage
3+
4+
# build generated
35
lib
46
dom
57
native
68
server
79
pure
810
.docz
911
site
12+
13+
# tests (need the !files because of the build generated above)
14+
coverage
15+
!src/dom
16+
!src/native
17+
!src/server
18+
19+
# settings from IDE
1020
.vscode

Diff for: jest.config.js

-7
This file was deleted.

Diff for: test/dom/asyncHook.ts renamed to src/dom/__tests__/asyncHook.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useRef, useEffect } from 'react'
2-
import { renderHook } from '../../src/dom'
2+
import { renderHook } from '..'
33

44
describe('async hook tests', () => {
55
const useSequence = (...values: string[]) => {

Diff for: test/native/autoCleanup.disabled.ts renamed to src/dom/__tests__/autoCleanup.disabled.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect } from 'react'
22

3-
import { ReactHooksRenderer } from 'types'
3+
import { ReactHooksRenderer } from '../../types/react'
44

55
// This verifies that if RHTL_SKIP_AUTO_CLEANUP is set
66
// then we DON'T auto-wire up the afterEach for folks
@@ -11,7 +11,7 @@ describe('skip auto cleanup (disabled) tests', () => {
1111
beforeAll(() => {
1212
process.env.RHTL_SKIP_AUTO_CLEANUP = 'true'
1313
// eslint-disable-next-line @typescript-eslint/no-var-requires
14-
renderHook = (require('../../src/native') as ReactHooksRenderer).renderHook
14+
renderHook = (require('..') as ReactHooksRenderer).renderHook
1515
})
1616

1717
test('first', () => {

Diff for: test/native/autoCleanup.noAfterEach.ts renamed to src/dom/__tests__/autoCleanup.noAfterEach.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect } from 'react'
22

3-
import { ReactHooksRenderer } from 'types'
3+
import { ReactHooksRenderer } from '../../types/react'
44

55
// This verifies that if RHTL_SKIP_AUTO_CLEANUP is set
66
// then we DON'T auto-wire up the afterEach for folks
@@ -13,7 +13,7 @@ describe('skip auto cleanup (no afterEach) tests', () => {
1313
// eslint-disable-next-line no-global-assign
1414
afterEach = false
1515
// eslint-disable-next-line @typescript-eslint/no-var-requires
16-
renderHook = (require('../../src/native') as ReactHooksRenderer).renderHook
16+
renderHook = (require('..') as ReactHooksRenderer).renderHook
1717
})
1818

1919
test('first', () => {

Diff for: test/dom/autoCleanup.ts renamed to src/dom/__tests__/autoCleanup.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect } from 'react'
2-
import { renderHook } from '../../src/dom'
2+
import { renderHook } from '..'
33

44
// This verifies that by importing RHTL in an
55
// environment which supports afterEach (like Jest)

Diff for: test/dom/cleanup.ts renamed to src/dom/__tests__/cleanup.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect } from 'react'
2-
import { renderHook, cleanup, addCleanup, removeCleanup } from '../../src/dom/pure'
2+
import { renderHook, cleanup, addCleanup, removeCleanup } from '../pure'
33

44
describe('cleanup tests', () => {
55
test('should flush effects on cleanup', async () => {

Diff for: test/dom/customHook.ts renamed to src/dom/__tests__/customHook.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useCallback } from 'react'
2-
import { renderHook, act } from '../../src/dom'
2+
import { renderHook, act } from '..'
33

44
describe('custom hook tests', () => {
55
function useCounter() {

Diff for: test/dom/errorHook.ts renamed to src/dom/__tests__/errorHook.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useEffect } from 'react'
2-
import { renderHook } from '../../src/dom'
2+
import { renderHook } from '..'
33

44
describe('error hook tests', () => {
55
function useError(throwError?: boolean) {

Diff for: test/dom/resultHistory.ts renamed to src/dom/__tests__/resultHistory.test.ts

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

33
describe('result history tests', () => {
44
let count = 0

Diff for: test/dom/suspenseHook.ts renamed to src/dom/__tests__/suspenseHook.test.ts

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

33
describe('suspense hook tests', () => {
44
const cache: { value?: Promise<string | Error> | string | Error } = {}

Diff for: test/dom/useContext.tsx renamed to src/dom/__tests__/useContext.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { createContext, useContext } from 'react'
2-
import { renderHook } from '../../src/dom'
2+
import { renderHook } from '..'
33

44
describe('useContext tests', () => {
55
test('should get default value from context', () => {

Diff for: test/dom/useEffect.ts renamed to src/dom/__tests__/useEffect.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect, useLayoutEffect } from 'react'
2-
import { renderHook } from '../../src/dom'
2+
import { renderHook } from '..'
33

44
describe('useEffect tests', () => {
55
test('should handle useEffect hook', () => {

Diff for: test/dom/useMemo.ts renamed to src/dom/__tests__/useMemo.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useMemo, useCallback } from 'react'
2-
import { renderHook } from '../../src/dom'
2+
import { renderHook } from '..'
33

44
describe('useCallback tests', () => {
55
test('should handle useMemo hook', () => {

Diff for: test/dom/useReducer.ts renamed to src/dom/__tests__/useReducer.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useReducer } from 'react'
2-
import { renderHook, act } from '../../src/dom'
2+
import { renderHook, act } from '..'
33

44
describe('useReducer tests', () => {
55
test('should handle useReducer hook', () => {

Diff for: test/dom/useRef.ts renamed to src/dom/__tests__/useRef.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useRef, useImperativeHandle } from 'react'
2-
import { renderHook } from '../../src/dom'
2+
import { renderHook } from '..'
33

44
describe('useHook tests', () => {
55
test('should handle useRef hook', () => {

Diff for: test/dom/useState.ts renamed to src/dom/__tests__/useState.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState } from 'react'
2-
import { renderHook, act } from '../../src/dom'
2+
import { renderHook, act } from '..'
33

44
describe('useState tests', () => {
55
test('should use setState value', () => {

Diff for: test/native/asyncHook.ts renamed to src/native/__tests__/asyncHook.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useRef, useEffect } from 'react'
2-
import { renderHook } from '../../src/native'
2+
import { renderHook } from '..'
33

44
describe('async hook tests', () => {
55
const useSequence = (...values: string[]) => {

Diff for: test/server/autoCleanup.disabled.ts renamed to src/native/__tests__/autoCleanup.disabled.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect } from 'react'
22

3-
import { ReactHooksRenderer } from 'types'
3+
import { ReactHooksRenderer } from '../../types/react'
44

55
// This verifies that if RHTL_SKIP_AUTO_CLEANUP is set
66
// then we DON'T auto-wire up the afterEach for folks
@@ -11,7 +11,7 @@ describe('skip auto cleanup (disabled) tests', () => {
1111
beforeAll(() => {
1212
process.env.RHTL_SKIP_AUTO_CLEANUP = 'true'
1313
// eslint-disable-next-line @typescript-eslint/no-var-requires
14-
renderHook = (require('../../src/server') as ReactHooksRenderer).renderHook
14+
renderHook = (require('..') as ReactHooksRenderer).renderHook
1515
})
1616

1717
test('first', () => {

Diff for: test/server/autoCleanup.noAfterEach.ts renamed to src/native/__tests__/autoCleanup.noAfterEach.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect } from 'react'
22

3-
import { ReactHooksRenderer } from 'types'
3+
import { ReactHooksRenderer } from '../../types/react'
44

55
// This verifies that if RHTL_SKIP_AUTO_CLEANUP is set
66
// then we DON'T auto-wire up the afterEach for folks
@@ -13,7 +13,7 @@ describe('skip auto cleanup (no afterEach) tests', () => {
1313
// eslint-disable-next-line no-global-assign
1414
afterEach = false
1515
// eslint-disable-next-line @typescript-eslint/no-var-requires
16-
renderHook = (require('../../src/server') as ReactHooksRenderer).renderHook
16+
renderHook = (require('..') as ReactHooksRenderer).renderHook
1717
})
1818

1919
test('first', () => {

Diff for: test/native/autoCleanup.ts renamed to src/native/__tests__/autoCleanup.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect } from 'react'
2-
import { renderHook } from '../../src/native'
2+
import { renderHook } from '..'
33

44
// This verifies that by importing RHTL in an
55
// environment which supports afterEach (like Jest)

Diff for: test/native/cleanup.ts renamed to src/native/__tests__/cleanup.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect } from 'react'
2-
import { renderHook, cleanup, addCleanup, removeCleanup } from '../../src/native/pure'
2+
import { renderHook, cleanup, addCleanup, removeCleanup } from '../pure'
33

44
describe('cleanup tests', () => {
55
test('should flush effects on cleanup', async () => {

Diff for: test/native/customHook.ts renamed to src/native/__tests__/customHook.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useCallback } from 'react'
2-
import { renderHook, act } from '../../src/native'
2+
import { renderHook, act } from '..'
33

44
describe('custom hook tests', () => {
55
function useCounter() {

Diff for: test/native/errorHook.ts renamed to src/native/__tests__/errorHook.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useEffect } from 'react'
2-
import { renderHook } from '../../src/native'
2+
import { renderHook } from '..'
33

44
describe('error hook tests', () => {
55
function useError(throwError?: boolean) {

Diff for: test/native/resultHistory.ts renamed to src/native/__tests__/resultHistory.test.ts

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

33
describe('result history tests', () => {
44
let count = 0

Diff for: test/native/suspenseHook.ts renamed to src/native/__tests__/suspenseHook.test.ts

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

33
describe('suspense hook tests', () => {
44
const cache: { value?: Promise<string | Error> | string | Error } = {}

Diff for: test/native/useContext.tsx renamed to src/native/__tests__/useContext.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { createContext, useContext } from 'react'
2-
import { renderHook } from '../../src/native'
2+
import { renderHook } from '..'
33

44
describe('useContext tests', () => {
55
test('should get default value from context', () => {

Diff for: test/native/useEffect.ts renamed to src/native/__tests__/useEffect.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect, useLayoutEffect } from 'react'
2-
import { renderHook } from '../../src/native'
2+
import { renderHook } from '..'
33

44
describe('useEffect tests', () => {
55
test('should handle useEffect hook', () => {

Diff for: test/native/useMemo.ts renamed to src/native/__tests__/useMemo.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useMemo, useCallback } from 'react'
2-
import { renderHook } from '../../src/native'
2+
import { renderHook } from '..'
33

44
describe('useCallback tests', () => {
55
test('should handle useMemo hook', () => {

Diff for: test/native/useReducer.ts renamed to src/native/__tests__/useReducer.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useReducer } from 'react'
2-
import { renderHook, act } from '../../src/native'
2+
import { renderHook, act } from '..'
33

44
describe('useReducer tests', () => {
55
test('should handle useReducer hook', () => {

Diff for: test/native/useRef.ts renamed to src/native/__tests__/useRef.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useRef, useImperativeHandle } from 'react'
2-
import { renderHook } from '../../src/native'
2+
import { renderHook } from '..'
33

44
describe('useHook tests', () => {
55
test('should handle useRef hook', () => {

Diff for: test/native/useState.ts renamed to src/native/__tests__/useState.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState } from 'react'
2-
import { renderHook, act } from '../../src/native'
2+
import { renderHook, act } from '..'
33

44
describe('useState tests', () => {
55
test('should use setState value', () => {

Diff for: test/server/asyncHook.ts renamed to src/server/__tests__/asyncHook.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState, useRef, useEffect } from 'react'
22

3-
import { renderHook } from '../../src/server'
3+
import { renderHook } from '..'
44

55
describe('async hook tests', () => {
66
const useSequence = (...values: string[]) => {

Diff for: test/dom/autoCleanup.disabled.ts renamed to src/server/__tests__/autoCleanup.disabled.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect } from 'react'
22

3-
import { ReactHooksRenderer } from 'types/react'
3+
import { ReactHooksRenderer } from '../../types/react'
44

55
// This verifies that if RHTL_SKIP_AUTO_CLEANUP is set
66
// then we DON'T auto-wire up the afterEach for folks
@@ -11,7 +11,7 @@ describe('skip auto cleanup (disabled) tests', () => {
1111
beforeAll(() => {
1212
process.env.RHTL_SKIP_AUTO_CLEANUP = 'true'
1313
// eslint-disable-next-line @typescript-eslint/no-var-requires
14-
renderHook = (require('../../src/dom') as ReactHooksRenderer).renderHook
14+
renderHook = (require('..') as ReactHooksRenderer).renderHook
1515
})
1616

1717
test('first', () => {

Diff for: test/dom/autoCleanup.noAfterEach.ts renamed to src/server/__tests__/autoCleanup.noAfterEach.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect } from 'react'
22

3-
import { ReactHooksRenderer } from 'types/react'
3+
import { ReactHooksRenderer } from '../../types/react'
44

55
// This verifies that if RHTL_SKIP_AUTO_CLEANUP is set
66
// then we DON'T auto-wire up the afterEach for folks
@@ -13,7 +13,7 @@ describe('skip auto cleanup (no afterEach) tests', () => {
1313
// eslint-disable-next-line no-global-assign
1414
afterEach = false
1515
// eslint-disable-next-line @typescript-eslint/no-var-requires
16-
renderHook = (require('../../src/dom') as ReactHooksRenderer).renderHook
16+
renderHook = (require('..') as ReactHooksRenderer).renderHook
1717
})
1818

1919
test('first', () => {

Diff for: test/server/autoCleanup.ts renamed to src/server/__tests__/autoCleanup.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect } from 'react'
2-
import { renderHook } from '../../src/server'
2+
import { renderHook } from '..'
33

44
// This verifies that by importing RHTL in an
55
// environment which supports afterEach (like Jest)

Diff for: test/server/cleanup.ts renamed to src/server/__tests__/cleanup.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect } from 'react'
2-
import { renderHook, cleanup } from '../../src/server'
2+
import { renderHook, cleanup } from '..'
33

44
describe('cleanup tests', () => {
55
test('should flush effects on cleanup', async () => {

Diff for: test/server/customHook.ts renamed to src/server/__tests__/customHook.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useCallback } from 'react'
2-
import { renderHook, act } from '../../src/server'
2+
import { renderHook, act } from '..'
33

44
describe('custom hook tests', () => {
55
function useCounter() {

Diff for: test/server/errorHook.ts renamed to src/server/__tests__/errorHook.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState, useEffect } from 'react'
22

3-
import { renderHook } from '../../src/server'
3+
import { renderHook } from '..'
44

55
describe('error hook tests', () => {
66
function useError(throwError?: boolean) {

Diff for: test/server/hydrationErrors.ts renamed to src/server/__tests__/hydrationErrors.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useCallback } from 'react'
2-
import { renderHook } from '../../src/server'
2+
import { renderHook } from '..'
33

44
describe('hydration errors tests', () => {
55
function useCounter() {

Diff for: test/server/useContext.tsx renamed to src/server/__tests__/useContext.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { createContext, useContext } from 'react'
2-
import { renderHook } from '../../src/server'
2+
import { renderHook } from '..'
33

44
describe('useContext tests', () => {
55
test('should get default value from context', () => {

Diff for: test/server/useEffect.ts renamed to src/server/__tests__/useEffect.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect } from 'react'
2-
import { renderHook } from '../../src/server'
2+
import { renderHook } from '..'
33

44
describe('useEffect tests', () => {
55
test('should handle useEffect hook', () => {

Diff for: test/server/useMemo.ts renamed to src/server/__tests__/useMemo.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useMemo, useCallback } from 'react'
2-
import { renderHook } from '../../src/server'
2+
import { renderHook } from '..'
33

44
describe('useCallback tests', () => {
55
test('should handle useMemo hook', () => {

Diff for: test/server/useReducer.ts renamed to src/server/__tests__/useReducer.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useReducer } from 'react'
2-
import { renderHook, act } from '../../src/server'
2+
import { renderHook, act } from '..'
33

44
describe('useReducer tests', () => {
55
test('should handle useReducer hook', () => {

Diff for: test/server/useRef.ts renamed to src/server/__tests__/useRef.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useRef, useImperativeHandle } from 'react'
2-
import { renderHook } from '../../src/server'
2+
import { renderHook } from '..'
33

44
describe('useHook tests', () => {
55
test('should handle useRef hook', () => {

0 commit comments

Comments
 (0)