Skip to content

Commit

Permalink
docs: improve custom puppeteer example to prevent worker warnings
Browse files Browse the repository at this point in the history
Prevents from warnings: A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --detectOpenHandles to find leaks. Active timers can also cause this, ensure that .unref() was called on them.
  • Loading branch information
falsyvalues committed Nov 17, 2022
1 parent 6e5b1d6 commit e0f0fe3
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Chore & Maintenance

- `[@jest/fake-timers]` Update `@sinonjs/fake-timers` ([#13612](https://github.com/facebook/jest/pull/13612))
- `[docs]` Improve custom puppeteer example to prevent worker warnings ([#13619](https://github.com/facebook/jest/pull/13619))

### Performance

Expand Down
3 changes: 3 additions & 0 deletions docs/Puppeteer.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class PuppeteerEnvironment extends NodeEnvironment {
}

async teardown() {
if (this.global.__BROWSER_GLOBAL__) {
this.global.__BROWSER_GLOBAL__.disconnect();
}
await super.teardown();
}

Expand Down
3 changes: 3 additions & 0 deletions website/versioned_docs/version-25.x/Puppeteer.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class PuppeteerEnvironment extends NodeEnvironment {
}

async teardown() {
if (this.global.__BROWSER_GLOBAL__) {
this.global.__BROWSER_GLOBAL__.disconnect();
}
await super.teardown();
}

Expand Down
3 changes: 3 additions & 0 deletions website/versioned_docs/version-26.x/Puppeteer.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class PuppeteerEnvironment extends NodeEnvironment {
}

async teardown() {
if (this.global.__BROWSER_GLOBAL__) {
this.global.__BROWSER_GLOBAL__.disconnect();
}
await super.teardown();
}

Expand Down
3 changes: 3 additions & 0 deletions website/versioned_docs/version-27.x/Puppeteer.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class PuppeteerEnvironment extends NodeEnvironment {
}

async teardown() {
if (this.global.__BROWSER_GLOBAL__) {
this.global.__BROWSER_GLOBAL__.disconnect();
}
await super.teardown();
}

Expand Down
3 changes: 3 additions & 0 deletions website/versioned_docs/version-28.x/Puppeteer.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class PuppeteerEnvironment extends NodeEnvironment {
}

async teardown() {
if (this.global.__BROWSER_GLOBAL__) {
this.global.__BROWSER_GLOBAL__.disconnect();
}
await super.teardown();
}

Expand Down
3 changes: 3 additions & 0 deletions website/versioned_docs/version-29.0/Puppeteer.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class PuppeteerEnvironment extends NodeEnvironment {
}

async teardown() {
if (this.global.__BROWSER_GLOBAL__) {
this.global.__BROWSER_GLOBAL__.disconnect();
}
await super.teardown();
}

Expand Down
3 changes: 3 additions & 0 deletions website/versioned_docs/version-29.1/Puppeteer.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class PuppeteerEnvironment extends NodeEnvironment {
}

async teardown() {
if (this.global.__BROWSER_GLOBAL__) {
this.global.__BROWSER_GLOBAL__.disconnect();
}
await super.teardown();
}

Expand Down
3 changes: 3 additions & 0 deletions website/versioned_docs/version-29.2/Puppeteer.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class PuppeteerEnvironment extends NodeEnvironment {
}

async teardown() {
if (this.global.__BROWSER_GLOBAL__) {
this.global.__BROWSER_GLOBAL__.disconnect();
}
await super.teardown();
}

Expand Down
3 changes: 3 additions & 0 deletions website/versioned_docs/version-29.3/Puppeteer.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class PuppeteerEnvironment extends NodeEnvironment {
}

async teardown() {
if (this.global.__BROWSER_GLOBAL__) {
this.global.__BROWSER_GLOBAL__.disconnect();
}
await super.teardown();
}

Expand Down

0 comments on commit e0f0fe3

Please sign in to comment.