Skip to content

[Bug]: SyntaxError: Unexpected token 'export' #35693

@Janealter

Description

@Janealter

Version

1.50.1

Steps to reproduce

  1. Make a package that exports TS files to use them in tests
  2. Import a TS module from this package in any test file

Expected behavior

Imported external TS module from the package should work as any local module

Actual behavior

Imported external TS module doesn't work because Playwright tries to run it differently than the local ones

Additional context

The log of playwright test shows:

SyntaxError: Unexpected token 'export'

   at shared/utils/prepare-test.ts:1

> 1 | import { PlaywrightUtils } from '@company/fe-kit/static/utils/playwright';
    | ^
  2 |
  3 | import { API_REGEX, INITIAL_REQUEST_DATA_MAP, WEBSOCKET_GLOB } from '../constants';
  4 | import { PlaywrightTestArgs } from '@playwright/test';
    at Object.<anonymous> (/Users/janealter/Projects/web-ui/e2e/shared/utils/prepare-test.ts:1:1)
    at Object.<anonymous> (/Users/janealter/Projects/web-ui/e2e/shared/utils/index.ts:2:1)
    at Object.<anonymous> (/Users/janealter/Projects/web-ui/e2e/Store Setup/Screens/Screen/Banners/Banner/image-pick.spec.ts:2:1)

The imported module is just a usual TS file with a few exports, nothing special

Environment

System:
    OS: macOS 15.4
    CPU: (12) arm64 Apple M3 Pro
    Memory: 76.25 MB / 36.00 GB
  Binaries:
    Node: 22.11.0 - ~/.nvm/versions/node/v22.11.0/bin/node
    npm: 10.9.0 - ~/.nvm/versions/node/v22.11.0/bin/npm
  Languages:
    Bash: 3.2.57 - /bin/bash
  npmPackages:
    @playwright/test: 1.50.1 => 1.50.1 
    playwright-test-coverage: 1.2.12 => 1.2.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions