Code Monkey home page Code Monkey logo

Comments (4)

bcheidemann avatar bcheidemann commented on September 13, 2024

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.

iuioiua avatar iuioiua commented on September 13, 2024

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.

kt3k avatar kt3k commented on September 13, 2024

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

@bcheidemann

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.

bcheidemann avatar bcheidemann commented on September 13, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.