Runner button not showing and No tests found

3 weeks ago 12
ARTICLE AD BOX

I am setting up Playwright + TypeScript + ESM with data‑driven tests (reading from an Excel file). However, in VS Code, the Playwright Test Runner button does not appear. In the terminal, Playwright says “No tests found” even when I pass the spec file name directly.

Command and error:

PS C:\MyWorkspace\Playwright> npx playwright test dataDrivenXLSX.spec.ts Error: No tests found. Make sure that arguments are regular expressions matching test files. You may need to escape symbols like "$" or "*" and quote the arguments.

I expect:

The VS Code runner button to show my tests. npx playwright test to detect and run my *.spec.ts tests. npx playwright test dataDrivenXLSX.spec.ts to run that file.

Project structure:

C:\MyWorkspace\Playwright ├─ sandbox\ │ └─ dataDrivenXLSX.spec.ts ├─ testdata\ │ └─ Login.xlsx ├─ playwright.config.ts ├─ tsconfig.json └─ package.json

Config files:

playwright.config.ts:

import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ testDir: '.', fullyParallel: false, forbidOnly: !!process.env.CI, retries: process.env.CI ? 2 : 0, workers: process.env.CI ? 1 : undefined, reporter: [ ['html'], ['allure-playwright'] ], use: { trace: 'on-first-retry', headless: false, screenshot: 'on-first-failure', video: 'on', baseURL: 'https://www.saucedemo.com/', }, metadata: { appUsername: '[email protected]', appPassword: 'test123' }, projects: [ { name: 'Google Chrome', use: { channel: 'chrome', viewport: null, launchOptions: { args: ['--start-maximized'], ignoreDefaultArgs: ['--window-size=1280, 720'] } }, }, ], });

tsconfig.json:

{ "compilerOptions": { // File Layout // "rootDir": "./src", // "outDir": "./dist", // Environment Settings "module": "nodenext", "target": "esnext", "moduleResolution": "nodenext", // Playwright + Node types // Purpose: Make TypeScript understand Playwright + Node global functions. "types": ["@playwright/test", "node"], // Other Outputs "sourceMap": true, "declaration": true, "declarationMap": true, // Stricter Typechecking Options "noUncheckedIndexedAccess": true, "exactOptionalPropertyTypes": false, // Recommended Options "strict": true, "jsx": "react-jsx", "verbatimModuleSyntax": false, "isolatedModules": true, "noUncheckedSideEffectImports": true, "moduleDetection": "force", "skipLibCheck": true, "strictNullChecks": false }, // Purpose: Tell TypeScript which files to type-check and compile. "include": ["tests/**/*.ts", "playwright.config.ts"] }

package.json:

{ "name": "playwrightproject", "version": "1.0.0", "main": "index.js", "type": "module", "scripts": { "test": "npx playwright test", "allure:generate": "npx allure generate allure-results --clean -o allure-report", "allure:open": "npx allure open allure-report" }, "keywords": [], "author": "", "license": "ISC", "description": "", "devDependencies": { "@playwright/test": "^1.56.1", "@types/node": "^24.10.1", "allure-commandline": "^2.34.1", "allure-playwright": "^3.4.2", "typescript": "^5.9.3" }, "dependencies": { "csv-parse": "^6.1.0", "xlsx": "^0.18.5" } }

Spec file (sandbox/dataDrivenXLSX.spec.ts):

import { test, expect } from '@playwright/test'; import path from "path"; import { fileURLToPath } from "url"; import XLSX from "xlsx"; interface LoginTestData { username: string, password: string, expectedResult: string } const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); function getLoginCreds(xlsxFileName: string): LoginTestData[] { const absolutePath = path.join(__dirname, "../testdata", xlsxFileName); const workbook = XLSX.readFile(absolutePath); const sheet = workbook.Sheets["Register"]; const users = XLSX.utils.sheet_to_json<LoginTestData>(sheet); return users; } const records = getLoginCreds("Login.xlsx"); for (const record of records) { test(`Login Test for ${record.username}`, async ({ page }) => { await page.goto('https://www.saucedemo.com'); await page.locator("#user-name").fill(record.username); await page.locator("#password").fill(record.password); await page.click("#login-button"); await page.waitForTimeout(1500); if (record.expectedResult === 'success') { await expect(page).toHaveURL(/inventory/); } else { const selector = page.locator("[data-test='error']"); await expect(selector).toBeVisible(); } }); }

I tried:

Ensured file name ends with .spec.ts. Tried both testDir: '.' and testDir: './tests'.

Still seeing no runner button and "No tests found".

Questions:

Why is Playwright not detecting any tests (both VS Code runner and CLI) even though my *.spec.ts file exists? Any VS Code setup required for the Playwright Test Explorer to show the runner?
Read Entire Article