Skip to content

assertSnapshot tests fail if repo path is less than 3 levels deep #7080

@dandv

Description

@dandv

If the repo is checked out at a path less than 3 levels deep, tests that depend on CWD being at least 3 levels from / will fail.

This poses problems in sandbox environments, where the code may be checked out at /deno/std instead of the typical /home/somedenodev/std.

  1. Check out the repo in a /code directory under root
  2. cd /code/std
  3. deno task ok

Expected behavior

No deno test ok failures, per CONTRIBUTING.md and AGENTS.md:

Actual output

assertSnapshot() - options ... mode => ./testing/snapshot_test.ts:287:11
error: AssertionError: unexpected output to stderr
    throw new AssertionError(msg);
          ^
    at assert (file:///code/deno-std-pure/assert/assert.ts:22:11)
    at file:///code/deno-std-pure/testing/snapshot_test.ts:333:7
    at async file:///code/deno-std-pure/testing/snapshot_test.ts:40:7
    at async innerWrapped (ext:cli/40_test.js:230:5)
    at async exitSanitizer (ext:cli/40_test.js:146:27)
    at async Object.outerWrapped [as fn] (ext:cli/40_test.js:173:14)
    at async TestContext.step (ext:cli/40_test.js:564:22)
    at async file:///code/deno-std-pure/testing/snapshot_test.ts:287:3

assertSnapshot() - update => ./testing/snapshot_test.ts:338:6
error: AssertionError: Unexpected Error:

Check ../../tmp/f8fdf6eb198f0022/test.ts


        throw new AssertionError(`Unexpected Error:\n\n${error}\n`);
              ^
    at assertNoError (file:///code/deno-std-pure/testing/snapshot_test.ts:373:15)
    at file:///code/deno-std-pure/testing/snapshot_test.ts:392:5
    at async file:///code/deno-std-pure/testing/snapshot_test.ts:40:7

assertSnapshot() - remove => ./testing/snapshot_test.ts:495:6
error: AssertionError: Unexpected Error:

Check ../../tmp/c75f90cba5f40891/test.ts


        throw new AssertionError(`Unexpected Error:\n\n${error}\n`);
              ^
    at assertNoError (file:///code/deno-std-pure/testing/snapshot_test.ts:524:15)
    at file:///code/deno-std-pure/testing/snapshot_test.ts:557:5
    at async file:///code/deno-std-pure/testing/snapshot_test.ts:40:7

assertSnapshot() - different directory => ./testing/snapshot_test.ts:612:6
error: AssertionError: Unexpected Error:

Check ../../tmp/ae46c315b1dc9240/test.ts
Check ../../tmp/6e893da85387d0f6/test.ts


        throw new AssertionError(`Unexpected Error:\n\n${error}\n`);
              ^
    at assertNoError (file:///code/deno-std-pure/testing/snapshot_test.ts:644:15)
    at file:///code/deno-std-pure/testing/snapshot_test.ts:688:5
    at async file:///code/deno-std-pure/testing/snapshot_test.ts:58:7

 FAILURES

assertSnapshot() - options ... mode => ./testing/snapshot_test.ts:287:11
assertSnapshot() - update => ./testing/snapshot_test.ts:338:6
assertSnapshot() - remove => ./testing/snapshot_test.ts:495:6
assertSnapshot() - different directory => ./testing/snapshot_test.ts:612:6

Environment

  • OS: Ubuntu 24.04
  • deno version: 2.7.11
  • std version: 1.0.18

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions