Skip to content

Conversation

davesmith00000
Copy link
Contributor

I found the instructions a bit magical, so I thought I'd spell out the usage a bit for the next person interested in trying it.

Based on the jsdom docs I had it in my head that I was was going to have to create a jsdom instance myself. "Is this plugin giving me a nice way to do that?" I wondered ...but after I read the source code I realised that this plugin is fully setting up node.js with a running dom instance (of course... makes much more sense 🤦 ).

Anyway I hope this helps someone.

document.body.appendChild(newDiv)

// Find the element by id on the page, and compare the contents
assertEquals(document.getElementById(id).innerHTML, content)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does MUnit reverse the meaning of the arguments to assertEquals? Normally the expected value is on the left, and the actual value on the right.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not know that. I've always treated it like a predicate e.g. if index == 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, I think it does flip them:

  test("assert") {
    assertEquals(1, 2)
  }

gives

values are not the same
=> Obtained
1
=> Diff (- obtained, + expected)
-1
+2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, then let's keep it as is.

@sjrd
Copy link
Member

sjrd commented Jan 22, 2022

LGTM. Could you squash everything in a single commit with a clean commit message, please?

The purpose of adding this example is to demystify the plugins usage, hopefully making it easier for people to get started.
@davesmith00000
Copy link
Contributor Author

Done, hopefully that's better. Sorry I was a bit hasty with the first version of the PR.

@sjrd sjrd merged commit b575012 into scala-js:main Jan 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants