Hello ,
In postman I am using cheerio to parse some html response . After conversion I get “ReferenceError: cheerio is not defined” :
ERRO[0003] ReferenceError: cheerio is not defined
running at post (file:///C:/prj/vbc/k6/k6-rest-api.js:82:27(11))
default at executePostrequest (file:///C:/prj/vbc/k6/libs/shim/core.js:1250:11(23))
at file:///C:/prj/vbc/k6/libs/shim/core.js:315:30(27)
at file:///C:/prj/vbc/k6/k6-rest-api.js:57:21(18)
at go.k6.io/k6/js/common.Bind.func1 (native)
at file:///C:/prj/vbc/k6/k6-rest-api.js:56:17(13) executor=per-vu-iterations scenario=default source=stacktrace
Manualy adding the following extra imports sort of makes it work :
import cheerio from "./libs/cheerio.js";
import URI from "./libs/urijs.js";
The problem is now that it takes 3 minutes with laptop fans maxed out to run the simple 1 VU 1 iteration with a few requests test.
I sense that I am importing cheerio that was already imported somewhere else.
Shouldn’t cheerio already be present in the pm converted tests?
If you are using any script file and getting "Uncaught ReferenceError: x is not defined " which means ‘x’ is either a variable or a method which you are trying to use before declaring it using var keyword. This means that there is a non-existent variable referenced somewhere. This variable needs to be declared, or you need to make sure it is available in your current script or scope otherwise , it will endup throwing this ‘x’ is not defined error . This usually indicates that your library is not loaded and JavaScript does not recognize the ‘x’.
To solve this error: Load your library at the beginning of all your scripts.
There can be multiple other reasons for this issue: