bootstrapAll
не работает, когда я запускаю codeceptjs
с командой:
npx codeceptjs run-workers 2
//codeceptjs configuration
//global.js is a file to set up global variable
bootstrapAll: "./global.js",
//global.js
let fs = require("fs");
let Path = require("path");
module.exports = async function () {
console.log('-----------xxxxxxxxxxxx');
clearFolders();
initLog4j();
initGlobalVariables();
};
function clearFolders() {
if (fs.existsSync("./application.log")) {
fs.unlinkSync("./application.log");
}
deleteFolderRecursive("./_output");
deleteFolderRecursive("./allure-report");
}
function deleteFolderRecursive(dir) {
if (fs.existsSync(dir)) {
fs.readdirSync(dir).forEach((file, index) => {
const curPath = Path.join(dir, file);
if (fs.lstatSync(curPath).isDirectory()) {
deleteFolderRecursive(curPath);
} else {
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(dir);
}
}
function initLog4j() {
global.log4js = require("log4js");
log4js.configure({
appenders: {
app: { type: "file", filename: "application.log" }
},
categories: {
default: { appenders: ["app"], level: "debug" }
}
});
}
function initGlobalVariables() {
global.assert = require("chai").assert;
global.ENV = process.env.ENV;
let chai = require("chai");
global.expect = chai.expect;
global.cons = require("./constants");
global.random = require("./util/random");
global.util = require("./util");
global.conf = require("./config");
global.req = require("./util/req.js");
global.bodys = require("./api/bodys");
global.paths = require("./api/paths");
global.moment = require("moment");
}
// Execute test command
npx codeceptjs run-workers 2
Согласно моему локальному журналу терминала, global.js
не было выполнено. Пожалуйста, сообщите, спасибо.