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

chore: fixes an issue with the e2e tests #4084

Merged
merged 1 commit into from
Jan 19, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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