k6 icon indicating copy to clipboard operation
k6 copied to clipboard

Test fails for transpiled JS using faker

Open thebpmgroup opened this issue 2 years ago • 1 comments

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

thebpmgroup avatar Aug 22 '22 11:08 thebpmgroup

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?

na-- avatar Aug 22 '22 15:08 na--

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.

mstoykov avatar Jun 20 '23 08:06 mstoykov