Skip to content

Commit 69054c6

Browse files
committed
chore: more manual fixes
1 parent bcce91f commit 69054c6

File tree

8 files changed

+26
-19
lines changed

8 files changed

+26
-19
lines changed

.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ module.exports = {
7272
'prefer-destructuring': 0,
7373
'@typescript-eslint/no-unused-vars': 0,
7474
'unicorn/no-await-expression-member': 0,
75+
'import/no-anonymous-default-export': 0,
76+
'no-shadow': 0,
77+
'@typescript-eslint/no-var-requires': 0,
78+
'require-await': 0,
7579
// esling-plugin-jest specific rules
7680
'jest/consistent-test-it': ['error', { fn: 'it', withinDescribe: 'it' }],
7781
'jest/no-disabled-tests': 0,

package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
"mock-fs": "^5.2.0",
8181
"netlify-plugin-cypress": "^2.2.1",
8282
"npm-run-all": "^4.1.5",
83+
"outdent": "^0.8.0",
8384
"pathe": "^1.1.0",
8485
"playwright-chromium": "1.28.1",
8586
"prettier": "^2.1.2",

test/helpers/edge.spec.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import type { PrerenderManifest } from 'next/dist/build'
22

3+
import { NEXT_PLUGIN_NAME } from '../../packages/runtime/src/constants'
34
import { generateRscDataEdgeManifest } from '../../packages/runtime/src/helpers/edge'
45

5-
jest.mock('../../packages/runtime/src/helpers/functionsMetaData', () => {
6-
const { NEXT_PLUGIN_NAME } = require('../../packages/runtime/src/constants')
7-
return {
6+
jest.mock('../../packages/runtime/src/helpers/functionsMetaData', () => ({
87
...jest.requireActual('../../packages/runtime/src/helpers/functionsMetaData'),
98
getPluginVersion: async () => `${NEXT_PLUGIN_NAME}@1.0.0`,
10-
}
11-
})
9+
}))
1210

1311
const basePrerenderManifest: PrerenderManifest = {
14-
version: 3,
12+
version: 4,
1513
routes: {},
1614
dynamicRoutes: {},
1715
notFoundRoutes: [],

test/helpers/files.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
getSourceFileForPage,
1515
} from '../../packages/runtime/src/helpers/files'
1616
import { Rewrites } from '../../packages/runtime/src/helpers/types'
17-
import { describeCwdTmpDir, moveNextDist } from '../test-utils'
17+
import { describeCwdTmpDir } from '../test-utils'
1818

1919
const TEST_DIR = resolve(__dirname, '..')
2020

@@ -110,7 +110,7 @@ describe('files utility functions', () => {
110110
}
111111
})
112112

113-
it('middleware tester matches root middleware', () => {
113+
it('middleware tester does not match undefined', () => {
114114
const paths = [
115115
'middl',
116116
'',

test/helpers/matchers.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { makeLocaleOptional, stripLookahead } from '../../packages/runtime/src/h
33

44
const makeDataPath = (path: string) => `/_next/data/build-id${path === '/' ? '/index' : path}.json`
55

6-
function checkPath(path: string, regex: string) {
6+
const checkPath = (path: string, regex: string) => {
77
const re = new RegExp(regex)
88
const dataPath = makeDataPath(path)
99
const testPath = re.test(path)
@@ -29,7 +29,7 @@ describe('the middleware path matcher', () => {
2929
// The regex generated by Next for the path "/static" with i18n enabled (>= 13.3.0)
3030
const regexTwo = '^(?:\\/(_next\\/data\\/[^/]{1,}))?(?:\\/((?!_next\\/)[^/.]{1,}))\\/static(.json)?[\\/#\\?]?$'
3131

32-
function assertion(input) {
32+
const assertion = (input) => {
3333
expect(checkPath('/static', input)).toBe(false)
3434
expect(checkPath('/static', makeLocaleOptional(input))).toBe(true)
3535
expect(checkPath('/en/static', makeLocaleOptional(input))).toBe(true)

test/helpers/verification.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ type FailBuild = NetlifyPluginUtils['build']['failBuild']
2121

2222
const chance = new Chance()
2323

24+
const { existsSync } = require('fs')
25+
2426
jest.mock('fs', () => ({
2527
...jest.requireActual('fs'),
2628
existsSync: jest.fn(),
2729
}))
2830

2931
describe('checkNextSiteHasBuilt', () => {
3032
let failBuildMock
31-
const { existsSync } = require('fs')
3233

3334
beforeEach(() => {
3435
failBuildMock = jest.fn() as unknown as FailBuild

test/index.spec.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { join , relative } from 'pathe'
1010
import { dir as getTmpDir } from 'tmp-promise'
1111

1212
// @ts-expect-error - TODO: Convert runtime export to ES6
13+
// eslint-disable-next-line import/default
1314
import nextRuntimeFactory from '../packages/runtime/src'
1415
import { HANDLER_FUNCTION_NAME, ODB_FUNCTION_NAME, IMAGE_FUNCTION_NAME } from '../packages/runtime/src/constants'
1516
import { watchForMiddlewareChanges } from '../packages/runtime/src/helpers/compiler'
@@ -44,6 +45,7 @@ const utils = {
4445
throw new Error(message)
4546
},
4647
},
48+
// eslint-disable-next-line no-void
4749
run: async () => void 0,
4850
cache: {
4951
save: jest.fn(),
@@ -101,15 +103,15 @@ afterEach(async () => {
101103
})
102104

103105
describe('preBuild()', () => {
104-
it('fails if publishing the root of the project', () => {
106+
it('fails if publishing the root of the project', async () => {
105107
defaultArgs.netlifyConfig.build.publish = path.resolve('.')
106-
expect(nextRuntime.onPreBuild(defaultArgs)).rejects.toThrow(
108+
await expect(nextRuntime.onPreBuild(defaultArgs)).rejects.toThrow(
107109
/Your publish directory is pointing to the base directory of your site/,
108110
)
109111
})
110112

111-
it('fails if the build version is too old', () => {
112-
expect(
113+
it('fails if the build version is too old', async () => {
114+
await expect(
113115
nextRuntime.onPreBuild({
114116
...defaultArgs,
115117
constants: { IS_LOCAL: true, NETLIFY_BUILD_VERSION: '18.15.0' },
@@ -118,7 +120,7 @@ describe('preBuild()', () => {
118120
})
119121

120122
it('passes if the build version is new enough', async () => {
121-
expect(
123+
await expect(
122124
nextRuntime.onPreBuild({
123125
...defaultArgs,
124126
constants: { IS_LOCAL: true, NETLIFY_BUILD_VERSION: '18.16.1' },
@@ -320,7 +322,7 @@ describe('onBuild()', () => {
320322
const failBuild = jest.fn().mockImplementation((err) => {
321323
throw new Error(err)
322324
})
323-
expect(() => nextRuntime.onBuild({ ...defaultArgs, utils: { ...utils, build: { failBuild } } })).rejects.toThrow(
325+
await expect(() => nextRuntime.onBuild({ ...defaultArgs, utils: { ...utils, build: { failBuild } } })).rejects.toThrow(
324326
`In most cases it should be set to ".next", unless you have chosen a custom "distDir" in your Next config.`,
325327
)
326328
expect(failBuild).toHaveBeenCalled()
@@ -334,7 +336,7 @@ describe('onBuild()', () => {
334336
})
335337
netlifyConfig.build.publish = path.resolve('out')
336338

337-
expect(() => nextRuntime.onBuild({ ...defaultArgs, utils: { ...utils, build: { failBuild } } })).rejects.toThrow(
339+
await expect(() => nextRuntime.onBuild({ ...defaultArgs, utils: { ...utils, build: { failBuild } } })).rejects.toThrow(
338340
`Your publish directory is set to "out", but in most cases it should be ".next".`,
339341
)
340342
expect(failBuild).toHaveBeenCalled()

0 commit comments

Comments
 (0)