Skip to content

Commit

Permalink
add some basic instructions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kent C. Dodds committed Apr 21, 2017
1 parent f8c7862 commit feb622c
Show file tree
Hide file tree
Showing 17 changed files with 188 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ npm-debug.log*
cypress/videos
cypress/screenshots
dist
.opt-in
65 changes: 65 additions & 0 deletions INSTRUCTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Instructions

> This is a work in progress, but I think it'll be much easier for you to know what to do to have it written out!
## API Unit Tests

- Run `npm start api.unit` to run the tests in watch mode
- Relevant files:
- You'll write your tests in: `api/src/routes/__tests__/utils.js`
- The source code you're testing is: `api/src/routes/utils.js`
- The demo is in: `api-final/demo/unit/`
- The solution is in: `api-final/src/routes/`

### TDD a new feature

Setup is the same as above!

> Remember to write a simple test to cover a simple use case. Then write code
> to make that test pass. Then refactor your code to clean it up if needed. Then
> continue the cycle until you cover all use cases.
### Fix the bug

- Run `npm start api.unit` to run the tests in watch mode
- Relevant files:
- You'll write your tests in: `api/src/models/__tests__/user.js`
- The bug is in: `api/src/models/user.js`
- The solution is in: `api-final/src/models/`

> Remember to first find the bug, reproduce it with a test, then fix the bug.
> That order is important!
## API Integration Tests

- Run `npm start api.integration` to run the tests in watch mode
- Relevant files:
- You'll write your tests in: `api/tests/integration/articles.test.js`
- The article's routes are defined in: `api/src/routes/api/articles.js`
- The demo is in: `api-final/demo/integration/`
- The solution is in: `api-final/tests/integration/`

## Client Unit Tests

- Run `npm start client.unit` to run the tests in watch mode
- Relevant files:
- You'll write your tests in: `src/reducers/__tests__/` and `src/screens/__tests__`
- The source code you're testing is next to those folders.
- The demo is in: `client-final/demo/unit/`
- The solution is in: `client-final/tests/unit/`

## Client Integration Tests

- Run `npm start client.integration` to run the tests in watch mode
- Relevant files:
- You'll write your tests in: `client/tests/integration/login.test.js`
- The login component is: `client/src/screens/login.js`
- The demo is: `client-final/tests/integration/register.test.js`
- The solution is: `client-final/tests/integration/login.test.js`

## End to End Tests

- Run `npm start e2e.dev` to run the tests in dev mode
- Relevant files:
- You'll write your tests in: `cypress/e2e/users_spec.js`
- You may find: `cypress/e2e/utils.js` useful
10 changes: 10 additions & 0 deletions api-final/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// FINAL_START
{
"rules": {
"import/no-extraneous-dependencies": "off",
"import/no-unresolved": "off",
"no-unused-vars": "off",

}
}
// FINAL_END
10 changes: 10 additions & 0 deletions api/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// FINAL_START
{
"rules": {
"import/no-extraneous-dependencies": "off",
"import/no-unresolved": "off",
"no-unused-vars": "off",

}
}
// FINAL_END
10 changes: 10 additions & 0 deletions client-final/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// FINAL_START
{
"rules": {
"import/no-extraneous-dependencies": "off",
"import/no-unresolved": "off",
"no-unused-vars": "off",

}
}
// FINAL_END
10 changes: 10 additions & 0 deletions client/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// FINAL_START
{
"rules": {
"import/no-extraneous-dependencies": "off",
"import/no-unresolved": "off",
"no-unused-vars": "off",

}
}
// FINAL_END
2 changes: 1 addition & 1 deletion client/src/screens/__tests__/__snapshots__/editor.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exports[`test renders editor form by default 1`] = `
data-state-key="description"
data-test="description"
onChange={[Function]}
placeholder="What's this article about?"
placeholder="What\'s this article about?"
type="text"
value="" />
</fieldset>
Expand Down
8 changes: 7 additions & 1 deletion cypress-final/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@
"globals": {
"cy": false,
"Cypress": false,
},
"rules": {
"import/no-extraneous-dependencies": "off",
"import/no-unresolved": "off",
"no-unused-vars": "off",

}
}
}
4 changes: 2 additions & 2 deletions cypress/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"globals": {
"cy": false,
"Cypress": false,
}
}
},
}
1 change: 1 addition & 0 deletions cypress/e2e/users_spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {sel} from '../utils'
describe('Users', () => {
// what kinds of things does a user do that we want to make sure
// doesn't break?
Expand Down
12 changes: 7 additions & 5 deletions package-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,13 @@ module.exports = {
},
validate: {
description: 'validates that things are set up properly',
script: concurrent.nps(
'lint',
'split.api.verify',
'split.client.verify',
'split.e2e.verify'
script: series(
'nps lint',
concurrent.nps(
'split.api.verify',
'split.client.verify',
'split.e2e.verify'
)
),
},
split: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"mkdirp": "^0.5.1",
"nps": "^5.0.5",
"nps-utils": "^1.2.0",
"opt-cli": "^1.5.1",
"p-series": "^1.0.0",
"prettier-eslint-cli": "^3.3.0",
"replace-in-file": "^2.5.0",
Expand Down
10 changes: 10 additions & 0 deletions templates/api/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// FINAL_START
{
"rules": {
"import/no-extraneous-dependencies": "off",
"import/no-unresolved": "off",
"no-unused-vars": "off",

}
}
// FINAL_END
10 changes: 10 additions & 0 deletions templates/client/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// FINAL_START
{
"rules": {
"import/no-extraneous-dependencies": "off",
"import/no-unresolved": "off",
"no-unused-vars": "off",

}
}
// FINAL_END
10 changes: 9 additions & 1 deletion templates/cypress/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,13 @@
"globals": {
"cy": false,
"Cypress": false,
},
// FINAL_START
"rules": {
"import/no-extraneous-dependencies": "off",
"import/no-unresolved": "off",
"no-unused-vars": "off",

}
}
// FINAL_END
}
9 changes: 9 additions & 0 deletions templates/cypress/e2e/users_spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
// COMMENT_START
/*
// COMMENT_END
// WORKSHOP_START
import {sel} from '../utils'
// WORKSHOP_END
// COMMENT_START
*/
// COMMENT_END
// FINAL_START
import {sel, getRandomUserData, createNewUser, loginAsNewUser} from '../utils'

Expand Down
27 changes: 25 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ [email protected]:
version "2.6.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.6.0.tgz#9df7e52fb2a0cb0fb89058ee80c3104225f37e1d"

commander@^2.8.1:
commander@2.9.0, commander@^2.8.1:
version "2.9.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4"
dependencies:
Expand Down Expand Up @@ -2773,6 +2773,10 @@ locate-path@^2.0.0:
p-locate "^2.0.0"
path-exists "^3.0.0"

lodash._baseclone@~4.5.0:
version "4.5.7"
resolved "https://registry.yarnpkg.com/lodash._baseclone/-/lodash._baseclone-4.5.7.tgz#ce42ade08384ef5d62fa77c30f61a46e686f8434"

lodash._baseget@^3.0.0:
version "3.7.2"
resolved "https://registry.yarnpkg.com/lodash._baseget/-/lodash._baseget-3.7.2.tgz#1b6ae1d5facf3c25532350a13c1197cb8bb674f4"
Expand All @@ -2787,6 +2791,12 @@ lodash.assign@^4.0.3, lodash.assign@^4.0.6:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7"

[email protected]:
version "4.3.2"
resolved "https://registry.yarnpkg.com/lodash.clone/-/lodash.clone-4.3.2.tgz#e56b176b6823a7dde38f7f2bf58de7d5971200e9"
dependencies:
lodash._baseclone "~4.5.0"

lodash.cond@^4.3.0:
version "4.5.2"
resolved "https://registry.yarnpkg.com/lodash.cond/-/lodash.cond-4.5.2.tgz#f471a1da486be60f6ab955d17115523dd1d255d5"
Expand Down Expand Up @@ -2863,7 +2873,7 @@ make-plural@~3.0.6:
optionalDependencies:
minimist "^1.2.0"

manage-path@^2.0.0:
manage-path@2.0.0, manage-path@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/manage-path/-/manage-path-2.0.0.tgz#f4cf8457b926eeee2a83b173501414bc76eb9597"

Expand Down Expand Up @@ -3225,6 +3235,15 @@ opn@^4.0.0:
object-assign "^4.0.1"
pinkie-promise "^2.0.0"

opt-cli@^1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/opt-cli/-/opt-cli-1.5.1.tgz#04db447b13c96b992eb31685266f4ed0d9736dc2"
dependencies:
commander "2.9.0"
lodash.clone "4.3.2"
manage-path "2.0.0"
spawn-command "0.0.2-1"

optionator@^0.8.2:
version "0.8.2"
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64"
Expand Down Expand Up @@ -3938,6 +3957,10 @@ spawn-command-with-kill@^1.0.0:
ps-tree "^1.1.0"
spawn-command "^0.0.2-1"

[email protected]:
version "0.0.2-1"
resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2-1.tgz#62f5e9466981c1b796dc5929937e11c9c6921bd0"

spawn-command@^0.0.2-1:
version "0.0.2"
resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2.tgz#9544e1a43ca045f8531aac1a48cb29bdae62338e"
Expand Down

0 comments on commit feb622c

Please sign in to comment.