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

Compiler errors importing JestPuppeteerConfig interface #545

Closed
colinrotherham opened this issue Mar 21, 2023 · 2 comments · Fixed by #547
Closed

Compiler errors importing JestPuppeteerConfig interface #545

colinrotherham opened this issue Mar 21, 2023 · 2 comments · Fixed by #547

Comments

@colinrotherham
Copy link
Contributor

colinrotherham commented Mar 21, 2023

🐛 Bug Report

I'm seeing TypeScript issues for properties not existing on JestPuppeteerConfig

To Reproduce

The issue can be seen when importing JestPuppeteerConfig into TypeScript:

import type { JestPuppeteerConfig } from "jest-environment-puppeteer";

For JavaScript, follow the Synchronous configuration README example but enable tsconfig.json checkJs: true

/** @type {import('jest-environment-puppeteer').JestPuppeteerConfig} */

Expected behavior

Compilation should complete without error but the following is shown:

node_modules/jest-environment-puppeteer/dist/index.d.ts:58:25 - error TS2339: Property 'browser' does not exist on type 'Global'.

58     var browser: Global["browser"];
                           ~~~~~~~~~

node_modules/jest-environment-puppeteer/dist/index.d.ts:59:22 - error TS2339: Property 'page' does not exist on type 'Global'.

59     var page: Global["page"];
                        ~~~~~~

node_modules/jest-environment-puppeteer/dist/index.d.ts:60:25 - error TS2339: Property 'context' does not exist on type 'Global'.

60     var context: Global["context"];
                           ~~~~~~~~~

node_modules/jest-environment-puppeteer/dist/index.d.ts:61:33 - error TS2339: Property 'puppeteerConfig' does not exist on type 'Global'.

61     var puppeteerConfig: Global["puppeteerConfig"];
                                   ~~~~~~~~~~~~~~~~~

node_modules/jest-environment-puppeteer/dist/index.d.ts:62:31 - error TS2339: Property 'jestPuppeteer' does not exist on type 'Global'.

62     var jestPuppeteer: Global["jestPuppeteer"];
                                 ~~~~~~~~~~~~~~~


Found 5 errors.

Link to repl or repo (highly encouraged)

Reproduced in example repo:
https://github.com/colinrotherham/jest-environment-puppeteeer-types

These types have // @ts-ignore so perhaps this is a known issue in jest-environment-puppeteer/src/env.ts?

declare global {
  // @ts-ignore
  var browser: Global["browser"];
  // @ts-ignore
  var page: Global["page"];
  // @ts-ignore
  var context: Global["context"];
  // @ts-ignore
  var puppeteerConfig: Global["puppeteerConfig"];
  // @ts-ignore
  var jestPuppeteer: Global["jestPuppeteer"];
}
@colinrotherham
Copy link
Contributor Author

colinrotherham commented Mar 21, 2023

Also looks like puppeteer LaunchOptions should be PuppeteerLaunchOptions

colinrotherham added a commit to alphagov/govuk-frontend that referenced this issue Mar 21, 2023
colinrotherham added a commit to alphagov/govuk-frontend that referenced this issue Mar 22, 2023
colinrotherham added a commit to alphagov/govuk-frontend that referenced this issue Mar 22, 2023
colinrotherham added a commit to alphagov/govuk-frontend that referenced this issue Mar 22, 2023
colinrotherham added a commit to alphagov/govuk-frontend that referenced this issue Mar 23, 2023
colinrotherham added a commit to alphagov/govuk-frontend that referenced this issue Mar 23, 2023
@gregberge
Copy link
Member

Hi @colinrotherham, sorry for the silence. I will give a look tomorrow and try to fix it! Thanks for the repro and all the details!

gregberge added a commit that referenced this issue Mar 24, 2023
Fix #545
Fix #546

jest-environment-puppeteer now exports `TestEnvironment`. Since custom environment creation was not public, it is not considered as a breaking change.
gregberge added a commit that referenced this issue Mar 24, 2023
Fix #545
Fix #546

jest-environment-puppeteer now exports `TestEnvironment`. Since custom environment creation was not public, it is not considered as a breaking change.
gregberge added a commit that referenced this issue Mar 24, 2023
Fix #545
Fix #546

jest-environment-puppeteer now exports `TestEnvironment`. Since custom environment creation was not public, it is not considered as a breaking change.
colinrotherham added a commit to alphagov/govuk-frontend that referenced this issue Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants