Skip to main content
logo

@codeceptjs-plugins

Set of plugins for the CodeceptJS framework written in an object-oriented way.

File structure
├── custom-plugin
│ ├── custom-plugin.ts
│ └── index.ts
└── codecept.conf.js
Create a plugin class that extends the BasePlugin class.
// custom-plugin.ts
import { BasePlugin, registerPlugin, BaseEvents } from '@codeceptjs-plugins/base'

export class CustomPlugin extends BasePlugin {
constructor(config) {
super(config, { namespace: 'my-custom-plugin' })
}

beforeSuite(suite: BaseEvents.suite.before): void {
this.logger.debug('Message from the beforeSuite handler: ', suite)
}
}
Build created plugin.
// index.ts
import { CustomPlugin } from './custom-plugin'

module.exports = (userSettings: Record<string, any>): CustomPlugin => {
const pluginInstance = registerPlugin(new CustomPlugin(userSettings))

return pluginInstance
}
Register created plugin in config.
// codecept.conf.js
module.exports = {
plugins: {
customPlugin: {
require: './custom-plugin',
enabled: true,
},
},
}