grafana / k6

A modern load testing tool, using Go and JavaScript - https://k6.io
GNU Affero General Public License v3.0
26.03k stars 1.27k forks source link

Test fails for transpiled JS using faker #2658

Closed thebpmgroup closed 1 year ago

thebpmgroup commented 2 years ago

Brief summary

I have written a simple test which uses faker. When I run the test from the command line (using the transpiled code producted by webpack) I get the following error

ERRO[0015] could not initialize './dist/testAccountPOST.js': could not load JS test 'file:///home/charlie/Documents/os-v3-k6/dist/testAccountPOST.js': SyntaxError: file:///home/charlie/Documents/os-v3-k6/dist/testAccountPOST.js: Unexpected token (204:11566)
  202 | 
  203 | ;// CONCATENATED MODULE: ./node_modules/@faker-js/faker/dist/esm/chunk-GCRDD34F.mjs
> 204 | var chunk_GCRDD34F_d=class extends Error{};var 

It looks like when babel bundles faker it is causing problems.

k6 version

k6 v0.39.0 (2022-07-05T10:50:14+0000/v0.39.0-0-g5904fd8, go1.18.3, linux/amd64)

OS

Ubuntu 22.04

Docker version and image (if applicable)

No response

Steps to reproduce the problem

Set up a simple project using typescript, webpack and import faker into your test file. Build using webpack. Execute the output file using K6 at the command line.

Expected behaviour

Test runs

Actual behaviour

Test does not run

na-- commented 2 years ago

This doesn't seem like a k6 bug, more like a babel/webpack bug :confused: Can you share a reproducible example? Maybe some git repo without any proprietary code, but with a babel config and a sample script that we can use to reproduce the error?

mstoykov commented 1 year ago

I am going to close this as we haven't had any new info for almost a year, and it looks very likely it had nothing to do with k6 being buggy.