codeceptjs / codeceptjs/CodeceptJS

Could not place bootstrap file on a different folder from config file

Đang mở
#2,437 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
4.2k
Fork
757
Merge trung bình
2 ngày 9 giờ
Pull request đã merge (30 ngày)
16

Mô tả

#### What are you trying to achieve?
I am trying to place a config file and bootstrap file in different folder
#### What do you get instead?
Returned `could not find bootstrap file`
> Provide console output if related. Use `--verbose` mode for more details.

```bash
npx codeceptjs run --grep "search" -c ./configs/puppeteer.conf.js --verbose

Hook /Users/study/WorkingSpace/amazonweb/configs/run_server.js doesn't exist

Error:
at module.exports (/Users/study/WorkingSpace/amazonweb/node_modules/codeceptjs/lib/hooks.js:12:13)
at Codecept.runBootstrap (/Users/study/WorkingSpace/amazonweb/node_modules/codeceptjs/lib/codecept.js:112:5)
at Command.module.exports (/Users/study/WorkingSpace/amazonweb/node_modules/codeceptjs/lib/command/run.js:30:14)
at Command.listener (/Users/study/WorkingSpace/amazonweb/node_modules/commander/index.js:315:8)
at Command.emit (events.js:315:20)
at Command.parseArgs (/Users/study/WorkingSpace/amazonweb/node_modules/commander/index.js:651:12)
at Command.parse (/Users/study/WorkingSpace/amazonweb/node_modules/commander/index.js:474:21)
at Object. (/Users/study/WorkingSpace/amazonweb/node_modules/codeceptjs/bin/codecept.js:228:9)
at Module._compile (internal/modules/cjs/loader.js:1147:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
```

> Provide test source code if related
1. Folder of bootstrap file placed in root folder: `./run_server`
2. Folder of configs file placed in: `./configs`, and contains files:
a. codecept_shared.js
```
const { setHeadlessWhen } = require("@codeceptjs/configure");
const SUT = require("./../SUT");

let config = {
tests: SUT.testSpecFolder,
output: SUT.outputFolder,
include: {
I: SUT.IObject,
PageFactory: SUT.pageFactory, // factory pattern to handle pages and common components
},
bootstrap: SUT.bootstrapFile,
mocha: {},
name: "amazon",
multiple: {
parallel: {
chunks: 2,
},
},
plugins: {
retryFailedStep: {
enabled: true,
},
screenshotOnFail: {
enabled: true,
},
allure: {
enabled: true,
},
stepByStepReport: {
enabled: false,
output: SUT.outputFolder,
},
rerun: {
// run 4 times until 1st success
minSuccess: 1,
maxReruns: 3,
},
},
};

module.exports = config
```

b. puppeteer.conf.js
```js
const { setHeadlessWhen } = require("@codeceptjs/configure");
const dotenv = require("dotenv").config();
const sharedConfig = require("./codecept_shared.js");

// turn on headless mode when running with HEADLESS=true environment variable
// HEADLESS=true npx codecept run

setHeadlessWhen(process.env.HEADLESS);
let helpers = {
Puppeteer: {
url: "https://www.amazon.com",
show: true,
windowSize: "1200x900",
waitForNavigation: ["domcontentloaded", "networkidle0"],
waitForTimeout: 5000,
chrome: {
args: [
"--incognito",
"--disable-extensions",
"--disable-gpu",
"--no-sandbox",
"--disable-dev-shm-usage",
],
},
},
ChaiWrapper: {
require: "codeceptjs-chai",
},
};
sharedConfig.helpers = helpers;
//console.log(sharedConfig);
exports.config = sharedConfig
```

3. SUT file
```
const path = require('path');

let projectBasedDir = '/Users/study/WorkingSpace/amazonweb';
// let bootstrapFile = path.join(projectBasedDir, '/run_server.js');
// console.log(bootstrapFile)
module.exports = {

testSpecFolder: path.join(projectBasedDir, '/tests/specs/**/*.spec.js'),
outputFolder: path.join(projectBasedDir,'/output'),
bootstrapFile: path.join(projectBasedDir, "./run_server.js"),
configFolder: path.join(projectBasedDir, '/configs'),
IObject: path.join(projectBasedDir,'/steps_file.js'),
pageFactory: path.join(projectBasedDir,'/tests/pageFactory.js')
}
```

### Details

```js
"allure-commandline": "^2.13.0",
"codeceptjs": "^2.6.5",
"codeceptjs-chai": "^1.1.1",
"dotenv": "^8.2.0",
"googleapis": "^39.2.0",
"playwright": "^1.1.1",
"puppeteer": "^3.3.0",
"rimraf": "^3.0.2"
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.