Open tb01923 opened 4 months ago
Update
setup the path inside of windows:
$PATH =[Environment]::GetEnvironmentVariable("PATH")
$rescript_test = 'C:\Program Files\nodejs\node_modules\rescript-test\bin\'
run retest
from the project folder as restest test/**/*.bs.js
and I am getting this error:
r> retest tests*\.bs.js node:internal/modules/esm/resolve:265 throw new ERR_MODULE_NOT_FOUND( ^
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\Users\tbrow\AppData\Roaming\nvm\v20.12.1\node_modules\rescript-test\src\Test.bs.js' imported from C:\Users\tbrow\AppData\Roaming\nvm\v20.12.1\node_modules\rescript-test\bin\retest.mjs at finalizeResolution (node:internal/modules/esm/resolve:265:11) at moduleResolve (node:internal/modules/esm/resolve:933:10) at defaultResolve (node:internal/modules/esm/resolve:1157:11) at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:390:12) at ModuleLoader.resolve (node:internal/modules/esm/loader:359:25) at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:234:38) at ModuleLoader.import (node:internal/modules/esm/loader:322:34) at importModuleDynamically (node:internal/modules/esm/translators:160:35) at importModuleDynamicallyCallback (node:internal/modules/esm/utils:225:14) at file:///C:/Users/tbrow/AppData/Roaming/nvm/v20.12.1/node_modules/rescript-test/bin/retest.mjs:42:41 { code: 'ERR_MODULE_NOT_FOUND', url: 'file:///C:/Users/tbrow/AppData/Roaming/nvm/v20.12.1/node_modules/rescript-test/src/Test.bs.js' }
Node.js v20.12.1
Stepping thorugh there is this bit of lines
glob(globOrName, (err, files) => {
if (err) {
reject(err);
} else {
resolve(files);
}
)
within retest.mjs
leverages this code from glob:
async function glob_(pattern, options = {}) {
return new Glob(pattern, options).walk();
}
/* snip */
export const glob = Object.assign(glob_, {
glob: glob_,
})
from glob/index.js
which in turn invokes: the Glob constructor:
constructor(pattern, opts) {...}
but the opts isn't a callback like the code in restest.mjs would indicate. further the walk object on that function just returns those files...
also glob documentation https://github.com/isaacs/node-glob shows the glob function returning a promise not callbacks
const results = await glob('**', { stat: true, withFileTypes: true })
Changing the code in https://github.com/bloodyowl/rescript-test/blob/main/bin/retest.mjs
from
if (globsOrNames.some((item) => item.includes("*"))) {
globsOrNames = await Promise.all(
globsOrNames.map(
(globOrName) =>
new Promise((resolve, reject) => {
glob(globOrName, (err, files) => {
if (err) {
reject(err);
} else {
resolve(files);
}
});
})
)
).then((arrays) => [...new Set([].concat(...arrays))]);
}
to
if (globsOrNames.some((item) => item.includes("*"))) {
globsOrNames = await Promise.all(
globsOrNames.map(
(globOrName) => glob(globOrName)
)
).then((arrays) => [...new Set([].concat(...arrays))]);
}
looks to fix the issue. @bloodyowl happy to issue a PR if this approach looks reasonable
Hello I am working on Windows 11 (my personal laptop) with ReScript 11. I am looking to learn more about ReScript and want to explore testing. This framework looks to be all i need, but it doesn't seem to be working correctly
node ./node_modules/rescript-test/bin/retest.mjs
node ./node_modules/rescript-test/bin/retest.mjs tests/entities/parser/test_parser.bs.js
node ./node_modules/rescript-test/bin/retest.mjs tests/entities/parser/*.bs.js
node ./node_modules/rescript-test/bin/retest.mjs tests/entities/**/test_parser.bs.js
I am a hobbiest at this point in my career (software executive) and have some rusty skills - so I may be missing something obviuos. I have added some debugging into
retest.mjs
and I don't think theglob
nodeback
is returning or isn't returning and the promises are not properly waited upon. The script does exit which indicates that the promises are not being waited on - but the code looks cool correct...Logging in the event that I am missing something obvious. Will update if I uncover anything else