playwright-api

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

API

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
    docs/api/class-xxx.md
    . For the new methods, params and options use the version from package.json (without -next).
  • 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
    packages/protocol/src/protocol.yml
    as needed
  • Watch will kick in and re-generate types for protocol channels
  • Implement dispatcher handler in
    packages/playwright/src/server/dispatchers/xxxDispatcher.ts
    as needed
  • Handler should just route the call into the corresponding method in
    packages/playwright-core/src/server/xxx.ts
  • Place new tests in
    tests/page/xxx.spec.ts
    or create new test file if needed
  • 在开始实现之前,请先通读步骤,以便理解并规划后续工作。请务必按顺序执行步骤,因为其中一些步骤是其他步骤的前提条件。
  • docs/api/class-xxx.md
    中定义(或更新)API。对于新方法、参数和选项,请使用package.json中的版本号(不含-next后缀)。
  • 监听机制会自动触发并重新生成API的类型定义
  • packages/playwright/src/client/xxx.ts
    中实现新API
  • 根据需要,在
    packages/protocol/src/protocol.yml
    中定义(或更新)API的通道
  • 监听机制会自动触发并重新生成协议通道的类型定义
  • 根据需要,在
    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
    tests/page/xxx.spec.ts
    and use page fixture. If you need to use browser context, place them in
    tests/library/xxx.spec.ts
    .
  • Run npm test as
    npm run ctest <file>
  • 如果您的测试仅使用page,请优先将其放在
    tests/page/xxx.spec.ts
    中并使用page fixture。如果需要使用浏览器上下文,请放在
    tests/library/xxx.spec.ts
    中。
  • npm run ctest <file>
    的形式运行npm测试

Lint

代码检查

  • In the end lint via
    npm run flint
    .
  • 最后通过
    npm run flint
    进行代码检查。