Open pajdekPL opened 11 months ago
If you open 'Problems' tab you should see the error:
Make sure the test file is currently open in the editor.
This is just a workaround and we could do a better job here surfacing the error in a more prominent way.
@yury-s This bug is more severe because tests working from command line but not from extension:
global.setup.ts
import dotenv from "dotenv";
async function globalSetup(): Promise<void> {
dotenv.config({ override: true });
}
export default globalSetup;
playwright.config.ts
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
globalSetup: 'global.setup.ts',
testDir: './tests',
});
example.spec.ts
import { test} from "@playwright/test";
function raiseErrorEnvNotSet(env: string): never {
throw new Error(`Please set ${env} env variable`);
}
const envVars = {
test: process.env.TEST ?? raiseErrorEnvNotSet("TEST"),
};
test("environmental variable TEST", async () => {
console.log("Env var TEST: ", process.env.TEST);
const test = envVars.test;
});
.env
TEST='hello form dotenv'
This configuration is valid, but error is presented in VSC Playwright extension
playwright.config.ts
import { defineConfig, devices } from '@playwright/test';
require('dotenv').config();
export default defineConfig({
globalSetup: 'global.setup.ts',
testDir: './tests',
});
Context:
Code Snippet Here is the repo that you can use to reproduce this bug: https://github.com/pajdekPL/pw-vcs-potential-bug
Describe the bug
The play test button arrow disappears when I throw an exception in one of my scripts:![image](https://github.com/microsoft/playwright/assets/17813470/3864fbc9-3089-49a6-a2f1-8384efb82834)
after commenting those two lines out:
https://github.com/pajdekPL/pw-vcs-potential-bug/blob/2df52bab0786792ad5c32307c0733529c76f0e3b/tests/example.spec.ts#L6 https://github.com/pajdekPL/pw-vcs-potential-bug/blob/2df52bab0786792ad5c32307c0733529c76f0e3b/tests/example.spec.ts#L7
The run button appears again:![image](https://github.com/microsoft/playwright/assets/17813470/6f2a50a5-bec5-43a2-bb7b-efab0c892e19)
The test work when executed directly from the console or the test explorer:
Add any other details about the problem here.