Comments (4)
This issue is likely happening because the permissions error is thrown in the "unload" callback, where the snapshot is opened. To avoid this, we can either ensure that such errors are logged properly by deno test
and/or assert that the required permissions are given before registering the callback in assertSnapshot
.
Happy to raise a PR for the latter fix. I'm not 100% sure where to start with the former, but also happy to raise a PR if pointed in the right direction.
from deno_std.
I'm unable to reproduce the reported error on my machine. The behavior is as expected. By the way, it should throw a PermissionDenied
error. Do you have any idea what the issue could be, @kt3k?
asher@Ashers-MacBook-Air x % deno test --allow-read -- -u
Check file:///Users/asher/Desktop/x/main_test.ts
running 1 test from ./main_test.ts
should match the snapshot ... FAILED (5ms)
ERRORS
should match the snapshot => ./main_test.ts:4:6
error: PermissionDenied: Requires write access to "/Users/asher/Desktop/x/__snapshots__", run again with the --allow-write flag
await Deno.mkdir(dir, { recursive: true });
^
at Object.mkdir (ext:deno_fs/30_fs.js:203:9)
at ensureDir (https://jsr.io/@std/fs/1.0.0-rc.2/ensure_dir.ts:41:16)
at eventLoopTick (ext:core/01_core.js:168:7)
at async ensureFile (https://jsr.io/@std/fs/1.0.0-rc.2/ensure_file.ts:42:7)
at async AssertSnapshotContext.#readSnapshotFile (https://jsr.io/@std/testing/0.225.3/snapshot.ts:402:7)
at async AssertSnapshotContext.getSnapshot (https://jsr.io/@std/testing/0.225.3/snapshot.ts:471:23)
at async assertSnapshot (https://jsr.io/@std/testing/0.225.3/snapshot.ts:585:20)
at async file:///Users/asher/Desktop/x/main_test.ts:5:3
deno 1.44.4 (release, aarch64-apple-darwin)
v8 12.6.228.9
typescript 5.4.5
from deno_std.
I was able to reproduce the issue with the below steps:
- First create a snapshot file with
-A
option - Run the same test with
--allow-read
option
$ deno test -A main_test.ts -- --update
running 1 test from ./main_test.ts
should match the snapshot ... ok (4ms)
------- post-test output -------
> 1 snapshot updated.
----- post-test output end -----
ok | 1 passed | 0 failed (6ms)
$ deno test --allow-read main_test.ts -- --update
running 1 test from ./main_test.ts
should match the snapshot ... ok (2ms)
Uncaught error from ./main_test.ts FAILED
ERRORS
./main_test.ts (uncaught error)
error: null
This error was not caught from a test and caused the test runner to fail on the referenced module.
It most likely originated from a dangling promise, event/timeout handler or top-level code.
FAILURES
./main_test.ts (uncaught error)
FAILED | 1 passed | 1 failed (5ms)
error: Test failed
To avoid this, we can either ensure that such errors are logged properly by deno test and/or assert that the required permissions are given before registering the callback in assertSnapshot.
Happy to raise a PR for the latter fix.
The latter solution sounds good to me
from deno_std.
@kt3k thanks for expanding on the replication steps :)
To avoid this, we can either ensure that such errors are logged properly by deno test and/or assert that the required permissions are given before registering the callback in assertSnapshot.
Happy to raise a PR for the latter fix.
The latter solution sounds good to me
I have now implemented this in #5201
from deno_std.
Related Issues (20)
- question(collections): `intersect()` function name differ from Set method name HOT 1
- docs: more thoroughly document `expect.toThrow()` behavior HOT 2
- feat request: add a pluralize word function HOT 4
- feat request: expose publicly `capitalizeWord` (or similar) HOT 10
- http/file-server, media_types: new addition `application/mp4` to mime db overrides `video/mp4` and breaks some net players HOT 7
- isGlob and globToRegExp do not support windows paths HOT 4
- feat req: add enums for WebSocket status HOT 1
- feat req (html): add a validator for custom name elements ? HOT 4
- to-do: add doc check for JSDoc tags that aren't needed
- to-do(yaml): document different YAML schemas
- proposal: remove `examplePath` option from `@std/dotenv/load`
- proposal: remove `defaultPath` from `@std/dotenv/load`
- Performance: `levenshteinDistance` becomes extremely slow for large edit distances HOT 6
- The windows logic in std/path breaks in DNT HOT 2
- tracking: support iterables in `@std/collections` APIs
- to-do: review custom error classes HOT 4
- suggestion: add CBOR encoding/decoding HOT 4
- to-do: fix unstable notices
- `@std/cli`: move informational output to `stderr` (instead of `stdout`) HOT 8
- `@std/async/deadline` with `@std/testing/time` doesn't work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deno_std.