【问题标题】:Is there a way to avoid the relative path in TestCafe?有没有办法避免 TestCafe 中的相对路径?
【发布时间】:2020-08-16 09:26:19
【问题描述】:

我想知道是否有人找到了 TestCafe 中相对路径地狱的解决方案,所以不要在我的固定装置中写这个:

import LoginPage from "../pages/citizen/login-page";

我想写:

import LoginPage from "Citizen/login-page";

目前使用:

  • testcafe:1.7.1
  • nodejs 8.12.0

【问题讨论】:

    标签: javascript testing automated-tests e2e-testing testcafe


    【解决方案1】:

    您可以使用path 模块进行目录解析。

    由于使用的是 ES5 的 import 语句,需要先下载@types/node 依赖。

    npm install --save-dev @types/node
    

    您的导入语句代码:

    import * as path from 'path';
    const dirPath = path.join(__dirname, '/login-page');
    

    【讨论】:

      猜你喜欢
      • 2019-09-07
      • 1970-01-01
      • 2014-11-25
      • 1970-01-01
      • 1970-01-01
      • 2021-01-09
      • 2019-05-29
      • 2017-05-18
      相关资源
      最近更新 更多