Skip to content
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

how to use zora with Deno? #77

Closed
andreswebs opened this issue Dec 12, 2020 · 3 comments
Closed

how to use zora with Deno? #77

andreswebs opened this issue Dec 12, 2020 · 3 comments
Labels

Comments

@andreswebs
Copy link

Doing an

import { test } from "https://raw.githubusercontent.com/lorenzofox3/zora/master/src/index.ts"

gives this error:

Download https://raw.githubusercontent.com/lorenzofox3/zora/master/src/reporter
Download https://raw.githubusercontent.com/lorenzofox3/zora/master/src/interfaces
Download https://raw.githubusercontent.com/lorenzofox3/zora/master/src/harness
Download https://raw.githubusercontent.com/lorenzofox3/zora/master/src/assertion
error: Import 'https://raw.githubusercontent.com/lorenzofox3/zora/master/src/reporter' failed: 404 Not Found
    at https://raw.githubusercontent.com/lorenzofox3/zora/master/src/index.ts:2:0
@lorenzofox3
Copy link
Owner

Hello.

To be honest I don't know: https://raw.githubusercontent.com/lorenzofox3/zora/master/src/reporter.ts exists, so it might be a bug in Deno's loader.

Maybe you can try by using this bundle file URL.

Perhaps @bdchauvette can help you. He is the only Deno's user I am aware of

@bdchauvette
Copy link
Contributor

bdchauvette commented Dec 14, 2020

You have to use the bundle URL and you won't be able to use any TS interfaces because the declarations use node-style path imports. Here's a minimal example.

The reason you have to use the bundle is that it's pretty much impossible to write TS sources that are compatible with both Deno and tsc. The issue is that Deno requires you to include .ts in the import path but the tsc itself does not allow you to import files ending with .ts (see e.g. microsoft/TypeScript#37582). As a result, you can either write TS sources that work with Deno or TS sources that work with tsc, but not both.

The reason the declarations don't work is again related to Deno's requirement that imports need to match the exact file name. The Zora typings are not bundled and they use Node-style extensionless paths. So even if you add a // @deno-types annotation (see below), it will fail when trying to import the other type files:

// @deno-types="https://unpkg.com/zora@4.0.1/dist/declarations/index.d.ts"
import { test } from 'https://unpkg.com/zora@4.0.1/dist/bundle/module.js';

In my case, I'm writing a cross-runtime lib, so I'm writing the tests with Node-style imports, then bundling everything together (with some changes based on target runtime) into tmp files, then running Node, Deno, QuickJS, etc. against the temp files. The only runtime support that I was missing from Zora was the ability to read env vars from the Deno object like it does with process in Node (#73).

If you're only supporting Deno, you should probably use Deno's builtin test framework or something like Rhum that targets Deno exclusively.


@lorenzofox3 -- Sorry for adding some maintenance overhead here 😓

I'm actually probably going to end up writing my own testing framework (no issue with Zora, I just prefer Mocha/Jest bdd-style structure for tests), so it might be simpler to revert #73 to avoid any confusion about Deno support 😬

@lorenzofox3
Copy link
Owner

lorenzofox3 commented Dec 15, 2020

Thanks for your thorough feedback @bdchauvette 👍 I'll close this one for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants