Open loganpowell opened 3 years ago
I have the same issue: TypeError: doctest is not a function
on Windows 10 OS.
I have tried to change version of Node.js, but still got the same error.
It might be the issue with Windows OS.
First off, thanks for a great module! I ❤️ doctests.
I don't think this is a Windows issue. My problem, at least, is that @supabase/doctest-js
is not a proper ES module. The example states
import doctest from "@supabase/doctest-js";
When using that in a "type": "module"
package, or a file with .mjs
extension, Node tries to import it as an ES module, which fails (doctest
will look like this:
{ default: [Function (anonymous)] }
And using e.g. doctest.default
also doesn't work, since the module itself is distributed as a CommonJS module.
For more information, see https://nodejs.org/api/esm.html.
The workarounds today seems to be to either use require
:
const { default: doctest } = require('@supabase/doctest-js');
Or (I haven't tested this) run your own code through e.g. babel, which will surely work its magic.
Investigating further, it seems as if it would be possible to use import
(while handling the .default
member somehow on the consuming side) by changing the code here:
to use dynamic imports instead of require
in the eval
.
Bug report
TypeError: doctest is not a function
Describe the bug
Following the
README
, I used this example:and my test:
I installed
mocha
globally and rannpm test
(after adding{..., "scripts": { "test": "mocha" } ... }
in mypackage.json
)ran
npm test
and got this:I saw that you're doing some Windows path work. Could the error be due to that?
System information