我正在尝试为github操作运行剧作家E2E测试,但到目前为止还没有成功。
- name: Run build and start
run: |
yarn build:e2e
yarn start:e2e &
- name: Run e2e
run: |
yarn e2e
我认为playwright
运行时服务器没有运行,因为所有的e2e测试都失败了。
运行构建并启动
Done in 192.91s.
yarn run v1.22.19
$ env-cmd -f environments/.env.e2e next start
ready - started server on 0.0.0.0:3000, url: ***
运行e2e
Test timeout of 270000ms exceeded while running "beforeEach" hook.
我非常确信剧作家无法从上一步连接到http://localhost:3000
,这就是为什么所有测试都超时的原因。
我遇到了类似的问题,我通过将其添加到playwright.config.ts 中来解决它
const config: PlaywrightTestConfig = {
// the rest of the options
webServer: {
command: 'yarn start',
url: 'http://localhost:3000/',
timeout: 120000,
},
use: {
baseURL: 'http://localhost:3000/',
},
// the rest of the options
};
export default config;
此外,我不需要在GitHub Actions工作流中启动yarn,只要构建yarn就足够了。
来源:https://github.com/microsoft/playwright/issues/14814