Hi,
I need to use an external library crypto
when running my k6 tests.
I’m using the example here: GitHub - grafana/k6-template-es6: Template repository for bundling test projects into single test scripts runnable by k6
However on running the tests, after running npm run-script webpack
, firstly it takes.a very long time start the tests, I see the memory (RAM) going up and up, and then I get the error:
ERRO[0105] TypeError: Cannot assign to read only property 'exports' at file:///Users/xxx/Desktop/k6-es6-master/build/app.bundle.js:10:364601(98)
Any ideas why - here’s the code:
In my test script:
import { sleep, check, group } from "k6";
import http from "k6/http";
import { Rate } from 'k6/metrics';
import Auth from './GreatAuth';
export function setup() {
let x = new GreatAuth(.....)
}
....
The GreatAuth file that uses crypto looks like:
var crypto = require("crypto");
class GreatAuth {
...
}
module.exports = GreatAuth;
And the webpack config is untouched from the example project I used but FYI:
var path = require('path');
var webpack = require('webpack');
module.exports = {
mode: "production",
entry: './main.js',
output: {
path: path.resolve(__dirname, 'build'),
libraryTarget: "commonjs",
filename: 'app.bundle.js'
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
}
]
},
stats: {
colors: true
},
target: "web",
externals: /k6(\/.*)?/,
devtool: 'source-map'
};
Any help would be appreciated.
Thanks.