denoland / denoland/std

Displaced lines in Actual / Expected diff

Open
#2,949 2 comments 1 reaction 0 assignees View on GitHub
bug testing
Dominant language
TypeScript
Stars
3.6k
Forks
681
PR merge metrics
No merged PRs in 30d

Description

Some of the lines from the `deno test` Actual / Expected diff are getting displaced.

`fetch.js`
```js
export async function fetchText() {
const response = await fetch(new URL("./file.txt", import.meta.url));
return await response.text();
}

export const _internals = { fetch };

```

`fetch_test.js`
```js
import { _internals, fetchText } from "./fetch.js";
import {
assertSpyCall,
returnsNext,
stub,
} from "https://deno.land/std@0.165.0/testing/mock.ts";
import { assertEquals } from "https://deno.land/std@0.165.0/testing/asserts.ts";

Deno.test("fetch mock", async () => {
const fetchTextStub = stub(_internals, "fetch", returnsNext(["fetched it"]));

try {
assertEquals(await fetchText(), "fetched it");
} finally {
fetchTextStub.restore();
}

assertSpyCall(fetchTextStub, 0, {
returned: "fetched it",
});
});

```

In the output 'fetched it' should be next to the `+` symbol in the Expected part but it is part of the 'Actual' lines
```
deno test --allow-read
running 1 test from ./fetch_test.js
fetch mock ... FAILED (40ms)
running 0 tests from ./sum.test.js

ERRORS

fetch mock => ./fetch_test.js:9:6
error: AssertionError: Values are not equal:

[Diff] Actual / Expected

- Hello File!\n
- fetched it
+

throw new AssertionError(message);
^
at assertEquals (https://deno.land/std@0.165.0/testing/asserts.ts:184:9)
at file:///C:/Users/GJZwiers/repos/medium/fetch_test.js:13:7

FAILURES

fetch mock => ./fetch_test.js:9:6

FAILED | 0 passed | 1 failed (79ms)

error: Test failed
```

`file.txt`
```
Hello File!

```

```
deno --version

deno 1.28.2 (release, x86_64-pc-windows-msvc)
v8 10.9.194.1
typescript 4.8.3
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.