我们如何将 Typescript 与 CodeceptJS 一起用于测试框架?
How can we use Typescript with CodeceptJS for testing framework?
我必须使用 CodeceptJS 创建一个测试框架。我正在尝试使用打字稿而不是 javascript 来编写我的页面对象和测试。有人可以帮助 conf.js 或 steps.ts 文件
中需要什么配置吗
我在 conf 文件中添加了以下内容,但不确定要添加什么
要求:["ts-node/register"、"should"]
- 将包
ts-node
添加到您的 package.json 开发依赖项中。并安装依赖项
- 将
require: ["ts-node/register"]
添加到配置。
- 确保您的
tests
配置中的正则表达式支持 ts
文件:
例如 tests: "./tests/*.spec.ts"
codeceptjs 的定义由命令 codeceptjs def
生成。
https://codecept.io/commands#typescript-definitions
您应该在 tsconfig 中添加此定义。
P.S.
有一个 TS&CodeceptJS 集成的例子:
https://github.com/elukoyanov/codecept-typescript-example
注意,它有一个用于主项目的 tsconfig(在项目目录中)和第二个仅用于 codeceptjs 的 tsconfig(在 src/specs/e2e
路径中)
现在有 TypeScript example from the CodeceptJS developers on Github.
官方文档也有step-by-step instructions for configuring TypeScript support.
我必须使用 CodeceptJS 创建一个测试框架。我正在尝试使用打字稿而不是 javascript 来编写我的页面对象和测试。有人可以帮助 conf.js 或 steps.ts 文件
中需要什么配置吗我在 conf 文件中添加了以下内容,但不确定要添加什么 要求:["ts-node/register"、"should"]
- 将包
ts-node
添加到您的 package.json 开发依赖项中。并安装依赖项 - 将
require: ["ts-node/register"]
添加到配置。 - 确保您的
tests
配置中的正则表达式支持ts
文件: 例如tests: "./tests/*.spec.ts"
codeceptjs 的定义由命令 codeceptjs def
生成。
https://codecept.io/commands#typescript-definitions
您应该在 tsconfig 中添加此定义。
P.S. 有一个 TS&CodeceptJS 集成的例子: https://github.com/elukoyanov/codecept-typescript-example
注意,它有一个用于主项目的 tsconfig(在项目目录中)和第二个仅用于 codeceptjs 的 tsconfig(在 src/specs/e2e
路径中)
现在有 TypeScript example from the CodeceptJS developers on Github.
官方文档也有step-by-step instructions for configuring TypeScript support.