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

[REGRESSION]: Wrong enum value when imported from another file #29302

Closed
ritz078 opened this issue Feb 1, 2024 · 3 comments · Fixed by #29308
Closed

[REGRESSION]: Wrong enum value when imported from another file #29302

ritz078 opened this issue Feb 1, 2024 · 3 comments · Fixed by #29308

Comments

@ritz078
Copy link

ritz078 commented Feb 1, 2024

I am doing react component testing

Context:

  • GOOD Playwright Version: 1.41.0
  • BAD Playwright Version: 1.41.2
  • Operating System: [e.g. Windows, Linux or Mac]: Mac
  • Extra: [any specific details about your environment]

Code Snippet

// CreateSignature.types.ts

 export enum ALLOWED_TABS {
  DRAW = "DRAW",
  TYPE = "TYPE",
  IMAGE = "IMAGE",
}
// x.spec.tsx
import { ALLOWED_TABS } from "../CreateSignature.types";

console.log(ALLOWED_TABS);

// This gives
// {
//  __pw_type: 'importRef',
//  id: 'recipes_src_components_CreateSignature_CreateSignature_types_ts_ALLOWED_TABS'
// }

When we define ALLOWED_TABS in other file and import it,

@ritz078 ritz078 changed the title [REGRESSION]: Enums in loop give duplicate error [REGRESSION]: Enums in loop give duplicate error when imported from other file Feb 1, 2024
@ritz078 ritz078 changed the title [REGRESSION]: Enums in loop give duplicate error when imported from other file [REGRESSION]: Wrong enum value when imported from another file Feb 1, 2024
@pavelfeldman
Copy link
Member

import { ALLOWED_TABS } from "../CreateSignature.types";

Playwright is struggling with non-standard file extension. It sounds like you are importing types information only, would it make sense to import types only?

import type { ALLOWED_TABS } from "../CreateSignature.types";

@ritz078
Copy link
Author

ritz078 commented Feb 1, 2024

@pavelfeldman I am importing from CreateSignature.types.ts (fixed in description. Sorry about that). I believe it should be standard TS extension for playwright ?

It sounds like you are importing types information only, would it make sense to import types only?

I am actually using the values in the file. So just importing the type won't help in this case.

@rahulkherajani
Copy link

rahulkherajani commented Feb 8, 2024

@pavelfeldman I am facing similar issues importing constants and other components when running component tests in 1.41.2.

I import my component like this

import {Component} from ./path;

and mount it like

await mount(<Component />)

When mounting, for some components I get this.. and tests work fine.

// {
//  __pw_type: 'importRef',
//  id: 'absolute_path_to_component'
// }

For others I don't get the importRef expression as above.. and the component doesnot mount..which fails the test.

PS. All tests work fine in 1.40.1

Could you provide an explaination for failure.
Also do I need to change the way I mount my components?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants