我想编写可重用的“之前”部分,但未能将变量从主文件(A.js)传递到导入的代码(HelloUtil.js)。提前感谢您提供的任何建议。
js
import * as UTIL from "./HelloUtil"
let variableFileA = "Hello"
// I hope the imported 'before' section is able to get 'variableFileA'
describe(`Do something`, () => {
it('A "It" section', () => {
cy.log("....")
});
})
HelloUtil.js
before('Reusable "before" 1', () => {
cy.log("lets begin....")
});
before('Reusable "before" 2', () => {
cy.log("print variable:"+variableFileA)
});
我收到的结果: