In postman I am using cheerio to parse some html response . After conversion I get “ReferenceError: cheerio is not defined” :
ERRO 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 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?
To solve this error: Load your library at the beginning of all your scripts.
There can be multiple other reasons for this issue: