deno: deno test --reporter junit get incorrect testsuite.name when use deno_std/testing/bdd.ts

//filename: test-reporter_test.ts
import { afterEach, beforeEach, it } from "https://deno.land/std@0.197.0/testing/bdd.ts";
import { assert } from "https://deno.land/std@0.197.0/assert/assert.ts";

it("test ok", ()=>{
   assert(true);
})
$ deno test -A   --reporter junit test-reporter_test.ts

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="deno test" tests="1" failures="0" errors="0" time="0.094">
    <testsuite name="https://deno.land/std@0.197.0/testing/_test_suite.ts" tests="1" disabled="0" errors="0" failures="0">
        <testcase name="test ok" time="0.009">
        </testcase>
    </testsuite>
</testsuites>

testsuite.name is https://deno.land/std@0.197.0/testing/_test_suite.ts, expect test-reporter_test.ts

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 27 (9 by maintainers)

Most upvoted comments

In the pass.ts file, does this look like what you had in mind for the new test? :

Deno.test("denoTestLocation", async () => {
  await Symbol.for("foo/bar/fizz.ts:100:200");
  throw 'error';
})

Not really, this is what I meant:

const testFn = () => {
  throw new Error("boom!")
};
testFn[Symbol.for("Deno.test.location")] = "foo/bar/fizz.ts:100:200";
Deno.test("denoTestLocation", testFn);

Regarding the assertion, I’ve never worked with .out files. I did some leg work to learn about common use practices with assertions in Deno, including reading the docs:https://deno.land/manual@v1.36.1/basics/testing/assertions, and couldn’t find an example of using it in the .out file. When I tried to input an assertion in said file, it wouldn’t show up in the output when I ran the tests. I feel like I still have a lot of gaps in how I should proceed, as well as how everything fits together. Would you mind if I asked for some help and advice on this?

This is really an internal API and not documented well in the contributing guide. Once you add a test like above in the pass.out you should add something like:

denoTestLocation => /foo/bar/fizz.ts:100:200
error: boom!
  throw new Error();
        ^
    at [WILDCARD]/test/fail.ts:29:9

I can’t say specifically if that will pass (most likely not), but please open a PR and we can work more easily from there.

move that bit that is looking for a location into a separate getTestCaseLocation() helper function In place where we assign location (testDesc.location = location) change the code to be testDesc.location = testDesc[Symbol.for(“Deno.test.location”)] || getTestCaseLocation()

I made the changes we referenced above for this part of the issue

Got some help over on Discord and got the integration tests running! This was the result:

test result: FAILED. 21 passed; 55 failed; 1 ignored; 0 measured; 1265 filtered out; finished in 5.07s
error: test failed, to rerun pass `-p deno --test integration_tests

I’ll go ahead and make the changes discussed earlier for this issue and rerun them.

Hey just wanted to give you a monday morning update. Over the weekend I had some trouble getting the repo running properly, ended up realizing that I missed the documentation on building it from the source. After following the instructions there everything seems to be working, I’m planning on making the changes we talked about later today.

@HoldUpFjord probably declared at the top level of the file - it would be used in several places in that file.

Awesome! I’ll get write on that then 😃 I’ll comment if I have any more questions or any updates. Appreciate all the support.

@HoldUpFjord so I would suggest to proceed as follows:

  • move that bit that is looking for a location into a separate getTestCaseLocation() helper function
  • In place where we assign location (testDesc.location = location) change the code to be testDesc.location = testDesc[Symbol.for("Deno.test.location")] || getTestCaseLocation()
  • Once we land this PR, we’ll adjust std/bdd.ts to assign proper Symbol.for("Deno.test.location") when the test cases are created

Awesome! Thanks so much @bartlomieju