Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled
161 lines
4.1 KiB
TypeScript
161 lines
4.1 KiB
TypeScript
import {
|
|
warnOptionHasBeenMovedOutOfExperimental,
|
|
warnOptionHasBeenDeprecated,
|
|
} from 'next/dist/server/config'
|
|
import stripAnsi from 'strip-ansi'
|
|
|
|
describe('warnOptionHasBeenMovedOutOfExperimental', () => {
|
|
let spy: jest.SpyInstance
|
|
beforeAll(() => {
|
|
spy = jest.spyOn(console, 'warn').mockImplementation((...args) => {
|
|
const [prefix, ...restArgs] = args
|
|
const formattedFirstArg = stripAnsi(prefix)
|
|
// pass the rest of the arguments to the spied console.warn
|
|
// @ts-expect-error accessing the mocked console.warn
|
|
console.warn.mock.calls.push([formattedFirstArg, ...restArgs])
|
|
})
|
|
})
|
|
|
|
it('should not log warning message without experimental config', () => {
|
|
warnOptionHasBeenMovedOutOfExperimental(
|
|
{},
|
|
'skipTrailingSlashRedirect',
|
|
'skipTrailingSlashRedirect',
|
|
'next.config.js',
|
|
false
|
|
)
|
|
|
|
warnOptionHasBeenMovedOutOfExperimental(
|
|
{
|
|
experimental: {},
|
|
},
|
|
'skipTrailingSlashRedirect',
|
|
'skipTrailingSlashRedirect',
|
|
'next.config.js',
|
|
false
|
|
)
|
|
|
|
expect(spy).not.toHaveBeenCalled()
|
|
})
|
|
|
|
it('should log warning message with removed experimental config', () => {
|
|
warnOptionHasBeenMovedOutOfExperimental(
|
|
{
|
|
experimental: {
|
|
skipTrailingSlashRedirect: true,
|
|
},
|
|
} as any,
|
|
'skipTrailingSlashRedirect',
|
|
'skipTrailingSlashRedirect',
|
|
'next.config.js',
|
|
false
|
|
)
|
|
|
|
expect(spy).toHaveBeenCalledWith(
|
|
expect.stringContaining(
|
|
'⚠ `experimental.skipTrailingSlashRedirect` has been moved to `skipTrailingSlashRedirect`. Please update your next.config.js file accordingly.'
|
|
)
|
|
)
|
|
})
|
|
|
|
it('should log warning message with removed experimental config - complex key', () => {
|
|
warnOptionHasBeenMovedOutOfExperimental(
|
|
{
|
|
experimental: {
|
|
relay: true,
|
|
},
|
|
} as any,
|
|
'relay',
|
|
'compiler.relay',
|
|
'next.config.js',
|
|
false
|
|
)
|
|
|
|
expect(spy).toHaveBeenCalledWith(
|
|
expect.stringContaining(
|
|
'⚠ `experimental.relay` has been moved to `compiler.relay`. Please update your next.config.js file accordingly.'
|
|
)
|
|
)
|
|
})
|
|
|
|
it('should update removed experimental config into new config', () => {
|
|
const config = {
|
|
experimental: {
|
|
skipTrailingSlashRedirect: true,
|
|
},
|
|
} as any
|
|
warnOptionHasBeenMovedOutOfExperimental(
|
|
config,
|
|
'skipTrailingSlashRedirect',
|
|
'skipTrailingSlashRedirect',
|
|
'next.config.js',
|
|
false
|
|
)
|
|
|
|
expect(config.experimental.skipTrailingSlashRedirect).toBe(true)
|
|
expect(config.skipTrailingSlashRedirect).toBe(true)
|
|
})
|
|
|
|
it('should update removed experimental config into new config - complex key', () => {
|
|
const config = {
|
|
experimental: {
|
|
foo: 'bar',
|
|
},
|
|
} as any
|
|
warnOptionHasBeenMovedOutOfExperimental(
|
|
config,
|
|
'foo',
|
|
'deep.prop.baz',
|
|
'next.config.js',
|
|
false
|
|
)
|
|
|
|
expect(config.experimental.foo).toBe('bar')
|
|
expect(config.deep.prop.baz).toBe('bar')
|
|
})
|
|
|
|
it('should show the new key name in the warning', () => {
|
|
const config = {
|
|
experimental: {
|
|
bundlePagesExternals: true,
|
|
},
|
|
} as any
|
|
|
|
warnOptionHasBeenMovedOutOfExperimental(
|
|
config,
|
|
'bundlePagesExternals',
|
|
'bundlePagesRouterDependencies',
|
|
'next.config.js',
|
|
false
|
|
)
|
|
|
|
expect(spy).toHaveBeenCalledWith(
|
|
expect.stringContaining(
|
|
'⚠ `experimental.bundlePagesExternals` has been moved to `bundlePagesRouterDependencies`. Please update your next.config.js file accordingly.'
|
|
)
|
|
)
|
|
})
|
|
})
|
|
|
|
describe('warnOptionHasBeenDeprecated', () => {
|
|
let spy: jest.SpyInstance
|
|
beforeAll(() => {
|
|
spy = jest.spyOn(console, 'warn').mockImplementation(() => {})
|
|
})
|
|
|
|
it('should warn experimental.appDir has been deprecated', () => {
|
|
const config = {
|
|
experimental: {
|
|
appDir: true,
|
|
},
|
|
} as any
|
|
warnOptionHasBeenDeprecated(
|
|
config,
|
|
'experimental.appDir',
|
|
'experimental.appDir has been removed',
|
|
false
|
|
)
|
|
expect(spy).toHaveBeenCalled()
|
|
})
|
|
})
|