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

chore(unit tests): Use side-effect import to fix TS errors #9754

Merged
merged 3 commits into from
Dec 26, 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
1 change: 1 addition & 0 deletions packages/forms/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
testEnvironment: 'jest-environment-jsdom',
}
1 change: 1 addition & 0 deletions packages/forms/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom'
6 changes: 0 additions & 6 deletions packages/forms/src/__tests__/form.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import React from 'react'

import {
toHaveFocus,
toHaveClass,
toBeInTheDocument,
} from '@testing-library/jest-dom/matchers'
import {
screen,
render,
Expand All @@ -27,7 +22,6 @@ import {
FieldError,
Label,
} from '../index'
expect.extend({ toHaveFocus, toHaveClass, toBeInTheDocument })

describe('Form', () => {
const TestComponent = ({ onSubmit = () => {} }) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/router/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
setupFilesAfterEnv: ['./jest.setup.js'],
setupFilesAfterEnv: ['./jest.setup.ts'],
testEnvironment: 'jest-environment-jsdom',
testMatch: ['**/*.test.+(ts|tsx|js|jsx)', '!**/__typetests__/*.ts'],
}
1 change: 0 additions & 1 deletion packages/router/jest.setup.js

This file was deleted.

3 changes: 3 additions & 0 deletions packages/router/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import '@testing-library/jest-dom'

globalThis.scrollTo = jest.fn()
5 changes: 0 additions & 5 deletions packages/router/src/__tests__/links.test.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import React from 'react'

import { toHaveClass, toHaveStyle } from '@testing-library/jest-dom/matchers'
import { render } from '@testing-library/react'

// TODO: Remove when jest configs are in place
// @ts-expect-error - Issue with TS and jest-dom
expect.extend({ toHaveClass, toHaveStyle })

import { NavLink, useMatch, Link } from '../links'
import { LocationProvider } from '../location'
import { flattenSearchParams } from '../util'
Expand Down
Loading