playwright-api
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAPI
API
Adding and modifying APIs
添加和修改API
- Before performing the implementation, go over the steps to understand and plan the work ahead. It is important to follow the steps in order, as some of them are prerequisites for others.
- Define (or update) API in . For the new methods, params and options use the version from package.json (without -next).
docs/api/class-xxx.md - Watch will kick in and re-generate types for the API
- Implement the new API in
packages/playwright/src/client/xxx.ts - Define (or update) channel for the API in as needed
packages/protocol/src/protocol.yml - Watch will kick in and re-generate types for protocol channels
- Implement dispatcher handler in as needed
packages/playwright/src/server/dispatchers/xxxDispatcher.ts - Handler should just route the call into the corresponding method in
packages/playwright-core/src/server/xxx.ts - Place new tests in or create new test file if needed
tests/page/xxx.spec.ts
- 在开始实现之前,请先通读步骤,以便理解并规划后续工作。请务必按顺序执行步骤,因为其中一些步骤是其他步骤的前提条件。
- 在中定义(或更新)API。对于新方法、参数和选项,请使用package.json中的版本号(不含-next后缀)。
docs/api/class-xxx.md - 监听机制会自动触发并重新生成API的类型定义
- 在中实现新API
packages/playwright/src/client/xxx.ts - 根据需要,在中定义(或更新)API的通道
packages/protocol/src/protocol.yml - 监听机制会自动触发并重新生成协议通道的类型定义
- 根据需要,在中实现调度器处理程序
packages/playwright/src/server/dispatchers/xxxDispatcher.ts - 处理程序只需将调用路由到中的对应方法即可
packages/playwright-core/src/server/xxx.ts - 将新测试用例放在中,如有需要可创建新的测试文件
tests/page/xxx.spec.ts
Build
构建
- Assume watch is running and everything is up to date.
- 假设监听机制正在运行,且所有内容均为最新版本。
Test
测试
- If your tests are only using page, prefer to place them in and use page fixture. If you need to use browser context, place them in
tests/page/xxx.spec.ts.tests/library/xxx.spec.ts - Run npm test as
npm run ctest <file>
- 如果您的测试仅使用page,请优先将其放在中并使用page fixture。如果需要使用浏览器上下文,请放在
tests/page/xxx.spec.ts中。tests/library/xxx.spec.ts - 以的形式运行npm测试
npm run ctest <file>
Lint
代码检查
- In the end lint via .
npm run flint
- 最后通过进行代码检查。
npm run flint