Skip to content

Instantly share code, notes, and snippets.

@scvnc
Last active April 21, 2023 00:13
Show Gist options
  • Save scvnc/b598c32779df7146e5fa5618af051405 to your computer and use it in GitHub Desktop.
Save scvnc/b598c32779df7146e5fa5618af051405 to your computer and use it in GitHub Desktop.
Video notes on "Vue NYC - Component Tests with Vue.js - Matt O'Connell"

Video notes on "Vue NYC - Component Tests with Vue.js - Matt O'Connell"

https://www.youtube.com/watch?v=OIpfWTThrK8

It is good but could use some clarification and revision 5 years later...


Reasons to test:

  1. Confidence/Removal of Fear to Change Code
  • The product that rhymes with "Packer" is a good example of this. Devs are afraid to touch the code and when we do, more regressions have arisen.
  1. Code Quality
    • Good testing -> higher code quality
      • SRP
      • Modular
      • Forces you to think about what my component really is doing?
  2. Tests are good documentation

Issue: Do not reach for the implementation detail

image

Correction

it('hides the logOut button if the user is not logged in', () => {
  expect(wrapper.findByInnerText('Log Out')).to.exist()
  wrapper.setProps({loggedIn: false}))
  expect(wrapper.findByInnerText('Log Out')).not.to.exist()
})

image

I disagree on #1... it is not testing the framework (vue)!

Input: myProp Output: DOM

We are not testing vue! Perhaps a non contrived example would be better:

it('displays the full name', () => {
  expect(wrapper.text()).toInclude(testProps.fullName)
})

I agree on #2, prop validation is vue framework and we shouldn't test that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment