Example configuration in CodeceptJS config:
plugins: {
elastic: {
require: './src/plugins/ElasticReporter.js',
enabled: false, // Set this to "true" if you want to activate plugin always. I prefer on-demand activation on command line with "-p elastic", thatswhy it is "false" in this Gist.
protocol: 'https',
server: 'MY_DNS_FOR_ELASTICSEARCH_SERVER', // <- REPLACE VALUE. Example value: 'elastic.example.org'
port: 9200,
index: `MY_NAME_OF_INDEX`, // <- REPLACE VALUE. Example value: 'qa-e2etests'
// Optional: Adjust configuration of custom fields to your needs.
// Every key/value pair you add here, will be added as a field in Elasticsearch index.
customFields: {
url: 'https://www.example.com',
environment: process.env.ENVIRONMENT,
testrun: 'Run-' + new Date(new Date().getTime() - (new Date().getTimezoneOffset() * 60000)).toISOString().slice(0, -5),
jenkinsJob: process.env.JOB_NAME
}
}
}
I think we could try axios which is already available when installing codeceptjs.
then we dont need to convert the JSON data to string