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

Correct some jest types #48923

Merged
merged 2 commits into from
Apr 28, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/next/src/build/jest/jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as Log from '../output/log'
import { findPagesDir } from '../../lib/find-pages-dir'
import { loadBindings, lockfilePatchPromise } from '../swc'
import type { JestTransformerConfig } from '../swc/jest-transformer'
import type { Config } from '@jest/types'

async function getConfig(dir: string) {
const conf = await loadConfig(PHASE_TEST, dir)
Expand Down Expand Up @@ -56,10 +57,14 @@ module.exports = createJestConfig(customJestConfig)
*/
export default function nextJest(options: { dir?: string } = {}) {
// createJestConfig
return (customJestConfig?: any) => {
return (
customJestConfig?:
| Config.InitialProjectOptions
| (() => Promise<Config.InitialProjectOptions>)
) => {
// Function that is provided as the module.exports of jest.config.js
// Will be called and awaited by Jest
return async () => {
return async (): Promise<Config.InitialProjectOptions> => {
let nextConfig
let jsConfig
let resolvedBaseUrl
Expand Down
3 changes: 2 additions & 1 deletion packages/next/src/build/swc/jest-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ import type {
import type { Config } from '@jest/types'
import type { NextConfig, ExperimentalConfig } from '../../server/config-shared'

export interface JestTransformerConfig {
type TransformerConfig = Config.TransformerConfig[1]
export interface JestTransformerConfig extends TransformerConfig {
jsConfig: any
resolvedBaseUrl?: string
pagesDir?: string
Expand Down