Boostrap - is not a function error


#1

Hi!
I’m trying build my custom runner, but when I start it I have error “TypeError: codecept.bootstrap is not a function”.

runner.js:

let Container = require('codeceptjs').container;
let Codecept = require('codeceptjs').codecept;
let config = require('codeceptjs').config.get();

let opts = { steps: true };

let codecept = new Codecept(config, opts);

codecept.initGlobals(__dirname);

Container.create(config, opts);

codecept.bootstrap();

codecept.loadTests('./test/test.js');

codecept.run();

codecept.json:

{
"tests": "test/test.js",
"timeout": 10000,
"output": "./output",
"helpers": {
	"Puppeteer": {
		"url": "",
		"browser": "chrome",
		"show": true,
		"restart": false
	}
     "bootstrap": "./server.js",
     "mocha": {},
     "name": "codetest"
}

server.js:

const server = require('selenium-standalone');

module.exports = {
   bootstrap: done => {
   server.start(done);
},
teardown: done => {
   server.stop(done);
}
}

Of course I installed selenium-standalone. Any idea why it doesn’t work?


#2

Hmm. I think the proper function name should be

/**

  • Executes bootstrap.
  • If bootstrap is async, second parameter is required.
  • @param {() => any} [done]
    */
    runBootstrap(done) {
    runHook(this.config.bootstrap, done, ‘bootstrap’);
    }

#3

Sorry, It’s consequences of my fix. (https://github.com/Codeception/CodeceptJS/pull/1270/)

Instead of codecept.bootstrap(); use codecept.runHooks() with codecept.runBootstrap();

I will fix docs in a few days


#4

Made PR, soon doc’ll be fixed


#5

Thanks for your help!