kentcdodds/testing-workshop

setup also solves exercise 01

goldylucks opened this issue · 7 comments

Coming from FEM
https://frontendmasters.com/courses/testing-javascript/

Environment info:

  • node version (node --version): v8.11.1
  • npm version (npm --version): 5.6.0
  • yarn version (yarn --version): 1.6.0 (I'm using npm like the workshop)

Problem description:
Setup doesn't work, or solves exercise 01.

Scenario A:

git clone https://github.com/kentcdodds/testing-workshop.git
cd testing-workshop
npm run setup --silent
git checkout fem
npm run dev # (works)
npm run start api.unit # throws nps not found

Scenario B:

git clone https://github.com/kentcdodds/testing-workshop.git
cd testing-workshop
git checkout fem # notice this has been moved BEFORE setup
npm run setup --silent
npm run dev # works
npm run start api.unit # works

But exercise 01 is already solved, and I'm guessing others as well.

// api/src/routes/utils/__tests__/get-token-from-header.js
import getTokenFromHeader from '../get-token-from-header'

test('getTokenFromHeader returns null if there is no token', () => {
  const result = getTokenFromHeader({headers: {}})
  expect(result).toBe(null)
})

test('getTokenFromHeader returns the token from the headers', () => {
  const token = 'hi.mom!'
  const authHeader = `Token ${token}`
  const req = {
    headers: {
      authorization: authHeader,
    },
  }

  const result = getTokenFromHeader(req)
  expect(result).toBe(token)
})
test('I submitted my elaboration and feedback', () => {
  const submitted = true
  expect(true).toBe(submitted)
})

To clarify, I haven't touche a single line of code yet.

running git diff yields the following:

	deleted:    api-final/.eslintrc
	deleted:    api-final/demo/integration/__tests__/users.js
	deleted:    api-final/demo/unit/__tests__/get-age.js
	deleted:    api-final/demo/unit/__tests__/make-me-a-sandwich.js
	deleted:    api-final/demo/unit/__tests__/sum.js
	deleted:    api-final/demo/unit/get-age.js
	deleted:    api-final/demo/unit/sum.js
	deleted:    api-final/src/models/__tests__/user.js
	deleted:    api-final/src/models/user.js
	deleted:    api-final/src/routes/utils/__tests__/arrayify.js
	deleted:    api-final/src/routes/utils/__tests__/get-token-from-header.js
	deleted:    api-final/src/routes/utils/arrayify.js
	deleted:    api-final/src/routes/utils/get-token-from-header.js
	deleted:    api-final/tests/integration/articles.test.js
	modified:   api/demo/integration/__tests__/users.js
	modified:   api/demo/unit/__tests__/get-age.js
	modified:   api/demo/unit/__tests__/make-me-a-sandwich.js
	modified:   api/demo/unit/__tests__/sum.js
	modified:   api/demo/unit/get-age.js
	modified:   api/demo/unit/sum.js
	modified:   api/src/models/__tests__/user.js
	modified:   api/src/models/user.js
	modified:   api/src/routes/utils/__tests__/arrayify.js
	modified:   api/src/routes/utils/__tests__/get-token-from-header.js
	modified:   api/src/routes/utils/arrayify.js
	modified:   api/tests/integration/articles.test.js
	deleted:    cypress-final/.eslintrc
	deleted:    cypress-final/e2e/users_spec.js
	modified:   cypress/.eslintrc
	modified:   cypress/e2e/users_spec.js

running git stash seems to solve it

git stash seems to solve it

You're running the old version of the workshop (2017 version). I'm guessing you'll want to watch the most recent (2018) version of the workshop which you can run with just the master branch :)

Where is it?

Just went through the courses on FEM, there's only one course with you on testing react apps, and is the one I'm watching now/

Oh you're right, I'm sorry about that. It should be released very soon (I thought it was going to be Wednesday). You can watch it unedited here: https://frontendmasters.com/workshops/testing-react-apps/

It should be officially released very soon though.

okie, I'll just to the old one for now, then the new one when it's released.

Your workshops are awesome btw, keep it up!

Thank you!