-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ReferenceError: global is not defined (version 4.3.4.2 and 4.3.4.3) #16
Comments
Hi @bdshadow, I recently found this out and discuss it in grafana/k6#3864 also related to grafana/k6#3860 Can you tell version of k6 you are using and As mentioned in the first issue this is coming from chaijs and has been fixed for years but a new version hasn't been released so that it works in other places apart from NodeJS. A workaround will be for you (or here in chaijs) for us to do the if you put in global.js globalThis.global = globalThis; and then in your file you have import "./global.js"
import { expect } from "https://jslib.k6.io/k6chaijs/4.3.4.3/index.js"
// rest of your code That should make it work |
@mstoykov thank you for your reply. First of all, I want to confirm that the described workaround works
We use k6 operator of version v0.0.13, which uses alpine image with the following k6: / # k6 version
k6 v0.51.0 (go1.22.4, linux/amd64)
Extensions:
github.com/grafana/xk6-browser v1.6.0, k6/x/browser [js]
github.com/grafana/xk6-browser v1.6.0, k6/x/browser/async [js]
github.com/grafana/xk6-loki v0.0.0-20240621131830-5248b47b4efd, k6/x/loki [js]
github.com/grafana/xk6-output-timescaledb v0.2.1, timescaledb [output]
github.com/szkiba/xk6-chai v0.1.1, k6/x/chai [js] About compatibility mode: env:
- name: K6_COMPATIBILITY_MODE
value: "base" |
Hi @bdshadow I would expect that given that you use This has finally been implemented but isn't realeased and is under heavy testing in order to be part of v0.53.0 to be released in August. But I will try to push the fix through the upstream and see how it goes. But I would expect it will be a while, and I doubt there will be a backport for v4.X of chai given that v5 exists. |
I' getting the following error
while running the following test:
The test is run in k8 by using https://github.com/grafana/k6-operator. When version is changed to 4.3.4.1, everything works fine, the problem starts from version 4.3.4.2.
Also, everything works fine locally.
I also tried to use https://github.com/szkiba/xk6-chai and update the dependency to "k6/x/chai", but it was the same ReferenceError only complaining about k6chaijs.min.js.
I'm a little lost in what theoretically can be the problem and what else can I check.
The text was updated successfully, but these errors were encountered: