Skip to content

Commit

Permalink
chore: fixes an issue where the e2e tests did not exit the process co…
Browse files Browse the repository at this point in the history
…rrectly (#4084)
  • Loading branch information
lukasholzer committed Jan 19, 2022
1 parent 1c7eb3b commit 7ec8cdc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
15 changes: 8 additions & 7 deletions tools/e2e/run.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env node
/* eslint-disable eslint-comments/disable-enable-pair, promise/prefer-await-to-callbacks */
const { join } = require('path')
const process = require('process')

Expand All @@ -11,28 +10,30 @@ const { setup } = require('./setup')
const main = async () => {
const { cleanup, registry, workspace } = await setup()

let statusCode = 0
// By default assume it is failing, so we don't have to set it when something goes wrong
// if it is going successful it will be set
let statusCode = 1

try {
console.log('Start running ava tests for **/*.e2e.js')
const { exitCode } = await execa('ava', ['**/*.e2e.js', '--config', join(process.cwd(), 'e2e.config.cjs')], {
stdio: 'inherit',
env: {
E2E_TEST_WORKSPACE: workspace,
E2E_TEST_REGISTRY: registry,
},
})

statusCode = exitCode
} catch (_error) {
} catch (error_) {
await cleanup()
console.error(_error instanceof Error ? _error.message : _error)
console.error(error_ instanceof Error ? error_.message : error_)
}

await cleanup()
process.exit(statusCode)
}

main().catch((error) => {
console.error(error)
main().catch((error_) => {
console.error(error_ instanceof Error ? error_.message : error_)
process.exit(1)
})
9 changes: 7 additions & 2 deletions tools/e2e/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,14 @@ const setup = async () => {
------------------------------------------`)

writeFileSync(join(workspace, '.npmrc'), registryWithAuth, 'utf-8')
} catch (_error) {
} catch (error_) {
await cleanup()
throw _error
throw new Error(
`npm publish failed for registry ${url.href}
Be sure not to have a ~/.npmrc in your home folder that specifies a different registry.
${error_ instanceof Error ? error_.message : error_}`,
)
}

return {
Expand Down

1 comment on commit 7ec8cdc

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Benchmark results

Package size: 355 MB

Please sign in to comment.