oak icon indicating copy to clipboard operation
oak copied to clipboard

Hitting snag when trying to run example test script

Open tnrich opened this issue 3 years ago • 1 comments

Here's the error I'm hitting when trying to run through this example https://deno.land/manual/testing/coverage : error: Relative import path "http" not prefixed with / or ./ or ../

Steps to repro:

# Go into your project's working directory
git clone https://github.com/oakserver/oak && cd oak

# Collect your coverage profile with deno test --coverage=<output_directory>
deno test --coverage=cov_profile


Download https://deno.land/[email protected]/bytes/mod.ts
Download https://deno.land/[email protected]/encoding/base64.ts
Download https://deno.land/[email protected]/http/http_status.ts
Download https://deno.land/[email protected]/io/readers.ts
Download https://deno.land/[email protected]/path/mod.ts
Download https://deno.land/[email protected]/streams/conversion.ts
Download https://deno.land/x/[email protected]/mod.ts
Download https://deno.land/x/[email protected]/index.ts
Download https://deno.land/[email protected]/async/deferred.ts
Download https://deno.land/[email protected]/io/buffer.ts
Download https://deno.land/[email protected]/io/bufio.ts
Download https://deno.land/[email protected]/io/writers.ts
Download https://deno.land/[email protected]/testing/asserts.ts
Download https://deno.land/[email protected]/bytes/equals.ts
Download https://deno.land/[email protected]/_util/os.ts
Download https://deno.land/[email protected]/path/_interface.ts
Download https://deno.land/[email protected]/path/common.ts
Download https://deno.land/[email protected]/path/glob.ts
Download https://deno.land/[email protected]/path/posix.ts
Download https://deno.land/[email protected]/path/separator.ts
Download https://deno.land/[email protected]/path/win32.ts
Download https://deno.land/[email protected]/_util/assert.ts
Download https://deno.land/[email protected]/bytes/bytes_list.ts
Download https://deno.land/[email protected]/io/types.d.ts
Download https://raw.githubusercontent.com/jshttp/mime-db/v1.52.0/db.json
Download https://deno.land/[email protected]/fmt/colors.ts
Download https://deno.land/[email protected]/testing/_diff.ts
Download https://deno.land/[email protected]/testing/_format.ts
Download https://deno.land/[email protected]/path/_constants.ts
Download https://deno.land/[email protected]/path/_util.ts
error: Relative import path "http" not prefixed with / or ./ or ../
    at file:///Users/tnrich/Sites/oak/http_server_node.ts:4:23

Thanks in advance!

tnrich avatar Jul 14 '22 22:07 tnrich

The example in the manual isn't quite working as-is. The specific issue with the import path is because an import map needs to be passed into the test command:

deno test --import-map=import-map.json --coverage=cov_profile

This will allow the test to run, but there's a bit more. If you want to run the tests properly, you should run the tests using Deno's task runner, which will have everything needed to run the tests properly:

deno task test

jcs224 avatar Jul 15 '22 01:07 jcs224

Correct, I would open an issue on the manual, as oak as evolved since that was written and requires some additional configuration due to its compatability now with being published as a npm package and being able to run under Node.js.

kitsonk avatar Aug 20 '22 21:08 kitsonk