Stay Hungry,Stay Foolish!

full-stack-fastapi-template --- End-to-End Testing with Playwright

full-stack-fastapi-template

End-to-End Testing with Playwright

https://github.com/fastapi/full-stack-fastapi-template/tree/master/frontend

 

切换到项目使用的node版本

 

nvm install 20

npm install
nvm use 20
npx playwright test

 

node版本来源:

https://github.com/fastapi/full-stack-fastapi-template/blob/master/frontend/Dockerfile.playwright

FROM node:20

WORKDIR /app

COPY package*.json /app/

RUN npm install

RUN npx -y playwright install --with-deps

COPY ./ /app/

ARG VITE_API_URL=${VITE_API_URL}

 

然后按照readme执行测试

End-to-End Testing with Playwright

The frontend includes initial end-to-end tests using Playwright. To run the tests, you need to have the Docker Compose stack running. Start the stack with the following command:

docker compose up -d --wait backend
 

Then, you can run the tests with the following command:

npx playwright test
 

You can also run your tests in UI mode to see the browser and interact with it running:

npx playwright test --ui
 

To stop and remove the Docker Compose stack and clean the data created in tests, use the following command:

docker compose down -v
 

To update the tests, navigate to the tests directory and modify the existing test files or add new ones as needed.

For more information on writing and running Playwright tests, refer to the official Playwright documentation.

 

 

docker模式测试

https://github.com/fastapi/full-stack-fastapi-template/blob/master/.github/workflows/playwright.yml

 

docker compose run --rm playwright npx playwright test
npx playwright show-report --host 0.0.0.0

 

posted @ 2025-01-27 10:40  lightsong  阅读(144)  评论(0)    收藏  举报
千山鸟飞绝,万径人踪灭