I am encountering an issue where I have a class named 'Button' and I am attempting to import it into my example.spec.ts file. Despite not receiving any errors from the compiler, when I run the test, an error is thrown:
Error: Cannot find module '/Users/.../automation/controls/Button' imported from /Users/.../automation/tests/example.spec.ts
The file structure is as follows:
controls
|
-> Button.ts
tests
|
-> example.spec.ts
Content of Button.ts:
class Button extends BaseElement{}
Content of exapmle.spec.ts:
import { test, expect } from '@playwright/test';
import Button from "../controls/Button";
test('Test Base Elements', async ({ page }) => {
const btnLocator: string = '[automation-id=next-button]';
const continueButton = new Button(page, btnLocator, 'Continue Button');
});
I am utilizing Playwright version 1.25.2