cypress在主等级库之前和之后执行等级库

cypress在主等级库之前和之后执行等级库,cypress,Cypress,我需要在运行主测试之后和之前执行header.spec.js。确保一切顺利通过 我在找这样的东西: before(function () { // I want here to call header.spec.js }); it(`check the work flow`, () => { // this is the main spec that will page context }) after(function () { // I want here to ca

我需要在运行主测试之后和之前执行header.spec.js。确保一切顺利通过

我在找这样的东西:

before(function () {
  // I want here to call header.spec.js
});

it(`check the work flow`, () => {
  // this is the main spec that will page context 
})

after(function () {
  // I want here to call footer.spec.js
});

如果我理解正确,您的header.spec.js和footer.spec.js是您只想执行的脚本?它们不包含任何测试?您正确地使用了之前和之后。要在这些钩子中执行Javascript文件,可以使用下面描述的cy.exec命令。例如,使用Node.js,您可以像这样运行这些文件,假设它们位于同一目录中:

cy.execnode header.spec.js; 希望我正确理解你的处境