簡體   English   中英

Testcafe 無法導入配置文件中的文件

[英]Testcafe can't import files in configuration file

使用 testcafe v1.17.0。

我有配置文件.testcaferc.js和新合並的全局鈎子屬性 在我的所有裝置中,我都有一個before鈎子,它對 API 執行一定數量的請求,並且通過新的全局鈎子,我想將所有這些 API 調用移動到配置文件中。 (刪除重復代碼等原因)

但是,似乎無法將其他文件或包導入到配置文件中,因為當我嘗試運行 testcafe 時它會引發以下錯誤:

An error has occurred while reading the "C:\\Users\\User\\Documents\\Projects\\testcafe\\.testcaferc.js" configuration file.

不太確定我需要在這里做什么才能完成這項工作。

我需要導入配置文件的內容有兩個示例。 它們中的任何一個都會引發上述錯誤。

import Shared from "./shared"; // Custom JS file containing functions for the API requests
import clonedeep from 'lodash.clonedeep';

.testcaferc.js配置文件應該是 CommonJS 格式,所以你應該使用require而不是import 您導入的模塊也應該以 cjs 格式編寫。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM