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

fix: stop using snapshot for checking invalid package json #5313

Merged
merged 5 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
52 changes: 0 additions & 52 deletions packages/build/tests/deploy/snapshots/tests.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,58 +51,6 @@ Generated by [AVA](https://avajs.dev).
(Netlify Build completed in 1ms)␊
Build step duration: Netlify Build completed in 1ms`

## Deploy plugin response syntax error

> Snapshot 1

`␊
Netlify Build ␊
β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€βŠ
␊
> Version␊
@netlify/build 1.0.0␊
␊
> Flags␊
buildbotServerSocket: /test/socket␊
debug: true␊
repositoryRoot: packages/build/tests/deploy/fixtures/empty␊
testOpts:␊
pluginsListUrl: test␊
silentLingeringProcesses: true␊
␊
> Current directory␊
packages/build/tests/deploy/fixtures/empty␊
␊
> Config file␊
packages/build/tests/deploy/fixtures/empty/netlify.toml␊
␊
> Resolved config␊
build:␊
publish: packages/build/tests/deploy/fixtures/empty␊
publishOrigin: default␊
␊
> Context␊
production␊
␊
Deploy site ␊
β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€βŠ
␊
␊
Internal error during "Deploy site" ␊
β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€βŠ
␊
Error message␊
Invalid response from buildbot: SyntaxError: Unexpected token e in JSON at position 1␊
␊
Error location␊
During Deploy site␊
STACK TRACE␊
␊
Resolved config␊
build:␊
publish: packages/build/tests/deploy/fixtures/empty␊
publishOrigin: default`

## Deploy plugin response system error

> Snapshot 1
Expand Down
Binary file modified packages/build/tests/deploy/snapshots/tests.js.snap
Binary file not shown.
5 changes: 3 additions & 2 deletions packages/build/tests/deploy/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ test('Deploy plugin connection error', async (t) => {
const { address, stopServer } = await startDeployServer()
await stopServer()
const output = await new Fixture('./fixtures/empty').withFlags({ buildbotServerSocket: address }).runWithBuild()
t.true(output.includes('Could not connect to buildbot: Error: connect'))
t.true(output.includes('Internal error during "Deploy site"'))
})

test('Deploy plugin response syntax error', async (t) => {
const { address, stopServer } = await startDeployServer({ response: 'test' })
try {
const output = await new Fixture('./fixtures/empty').withFlags({ buildbotServerSocket: address }).runWithBuild()
t.snapshot(normalizeOutput(output))
// This shape of this error can change with different Node.js versions.
t.true(output.includes('Internal error during "Deploy site"'))
} finally {
await stopServer()
}
Expand Down
52 changes: 0 additions & 52 deletions packages/build/tests/functions/snapshots/tests.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,58 +283,6 @@ Generated by [AVA](https://avajs.dev).
(Netlify Build completed in 1ms)␊
Build step duration: Netlify Build completed in 1ms`

## Functions: invalid package.json

> Snapshot 1
`␊
Netlify Build ␊
β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€βŠ
␊
> Version␊
@netlify/build 1.0.0␊
␊
> Flags␊
debug: true␊
repositoryRoot: packages/build/tests/functions/fixtures/functions_package_json_invalid␊
testOpts:␊
pluginsListUrl: test␊
silentLingeringProcesses: true␊
␊
> Current directory␊
packages/build/tests/functions/fixtures/functions_package_json_invalid␊
␊
> Config file␊
packages/build/tests/functions/fixtures/functions_package_json_invalid/netlify.toml␊
␊
> Resolved config␊
build:␊
publish: packages/build/tests/functions/fixtures/functions_package_json_invalid␊
publishOrigin: default␊
functionsDirectory: packages/build/tests/functions/fixtures/functions_package_json_invalid/functions␊
␊
> Context␊
production␊
␊
Functions bundling ␊
β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€βŠ
␊
Packaging Functions from functions directory:␊
- test.js␊
␊
␊
Configuration error ␊
β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€βŠ
␊
Error message␊
Unexpected token { in JSON at position 1␊
␊
Resolved config␊
build:␊
publish: packages/build/tests/functions/fixtures/functions_package_json_invalid␊
publishOrigin: default␊
functionsDirectory: packages/build/tests/functions/fixtures/functions_package_json_invalid/functions`

## Functions: --functionsDistDir

> Snapshot 1
Expand Down
Binary file modified packages/build/tests/functions/snapshots/tests.js.snap
Binary file not shown.
3 changes: 2 additions & 1 deletion packages/build/tests/functions/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ test('Functions: invalid package.json', async (t) => {
await writeFile(packageJsonPath, '{{}')
try {
const output = await new Fixture('./fixtures/functions_package_json_invalid').runWithBuild()
t.snapshot(normalizeOutput(output))
// This shape of this error can change with different Node.js versions.
t.true(output.includes('in JSON at position 1'))
} finally {
await rm(packageJsonPath, { force: true, recursive: true, maxRetries: 10 })
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export const onPreBuild = function ({ netlifyConfig }) {
netlifyConfig.functions.node_bundler = 'esbuild'
netlifyConfig.functions.test = {}

netlifyConfig.functions.test.included_files = []

netlifyConfig.functions.test = { included_files: [] }
}
Loading
Loading