I have a problem, I have this test under the name “login.ok.ts” (It is saved in VSC with a blue icon).
import { test, expect } from '@playwright/test';
test('Login and Verify Products Page', async ({ page }) => {
// Navega a la página de inicio de sesión de SauceDemo
await page.goto('https://www.saucedemo.com/');
// Llena el campo de nombre de usuario
await page.fill('#user-name', 'standard_user');
// Llena el campo de contraseña
await page.fill('#password', 'secret_sauce');
// Haz clic en el botón de inicio de sesión
await page.click('#login-button');
// Espera a que se cargue la página de productos
await page.waitForSelector('#inventory_container');
// Verifica que el texto "Products" esté presente en la página
const pageTitle = await page.innerText('.title');
expect(pageTitle).toContain('Products');
});
test('Login Error Message', async ({ page }) => {
// Navega a la página de inicio de sesión de SauceDemo
await page.goto('https://www.saucedemo.com/');
// Llena el campo de nombre de usuario
await page.fill('#user-name', 'standard_user');
// Llena el campo de contraseña con una contraseña incorrecta
await page.fill('#password', 'asdssadasd');
// Haz clic en el botón de inicio de sesión
await page.click('#login-button');
// Espera a que aparezca el mensaje de error
await page.waitForSelector('h3');
// Verifica que el mensaje de error diga "Epic sadface: Username and password do not match any user in this service"
const errorMessage = await page.innerText('h3');
expect(errorMessage).toContain('Epic sadface: Username and password do not match any user in this service');
});
When I run it with “npx playwright test login.ok.ts” (being in the location where this code is saved) I get this error:
PS E:My codes> npx playwright test login.ok.ts
> [email protected] npx
> playwright test login.ok.ts
Error: No tests found.
Make sure the arguments are regular expressions that match the test files.
You may need to escape symbols such as "$" or "*" and enclose the arguments in quotes.
But if I in that same path create a file named “example.spec.ts”(It is saved in VSC with an orange icon) and copy the SAME code, it fires without problems.
I do not understand where the error can be
solutionsolutionsolution