Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an example to the README #52

Merged
merged 1 commit into from Jan 22, 2022
Merged

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.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
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.

None yet

2 participants