test: crash mocha if unhandled errors occur (#11055)

This commit is contained in:
Alex Rudenko 2023-09-29 11:32:53 +02:00 committed by GitHub
parent c5f2d28b76
commit 28c1c2662a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 5 deletions

View File

@ -175,6 +175,8 @@ jobs:
run: npm ci
env:
PUPPETEER_SKIP_DOWNLOAD: true
# Set up GitHub Actions caching for Wireit.
- uses: google/wireit@f3a3c79c553122e2fe5829eeac7d815326502903 # setup-github-actions-caching/v1
- name: Build packages
run: npm run build --workspace @puppeteer-test/test
- name: Setup cache for Chrome binary
@ -263,6 +265,8 @@ jobs:
run: npm ci
env:
PUPPETEER_SKIP_DOWNLOAD: true
# Set up GitHub Actions caching for Wireit.
- uses: google/wireit@f3a3c79c553122e2fe5829eeac7d815326502903 # setup-github-actions-caching/v1
- name: Build packages
run: npm run build --workspace @puppeteer-test/test
- name: Setup cache for Firefox binary

View File

@ -27,4 +27,9 @@ module.exports = {
parallel: !!process.env.PARALLEL,
timeout: timeout,
reporter: process.env.CI ? 'spec' : 'dot',
// This should make mocha crash on uncaught errors.
// See https://github.com/mochajs/mocha/blob/master/docs/index.md#--allow-uncaught.
allowUncaught: true,
// See https://github.com/mochajs/mocha/blob/master/docs/index.md#--async-only--a.
asyncOnly: true,
};

View File

@ -690,7 +690,7 @@ describe('ElementHandle specs', function () {
Puppeteer.customQueryHandlerNames();
expect(handlerNamesAfterUnregistering.includes('getById')).toBeFalsy();
});
it('should throw with invalid query names', () => {
it('should throw with invalid query names', async () => {
try {
Puppeteer.registerCustomQueryHandler('1/2/3', {
queryOne: () => {

View File

@ -249,10 +249,6 @@ if (
);
}
process.on('unhandledRejection', reason => {
throw reason;
});
const browserNotClosedError = new Error(
'A manually launched browser was not closed!'
);