From feb622c9a8c81c7e5f739fcdeadd12b09d086f46 Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Fri, 21 Apr 2017 12:28:12 -0600 Subject: [PATCH] add some basic instructions. --- .gitignore | 1 + INSTRUCTIONS.md | 65 +++++++++++++++++++ api-final/.eslintrc | 10 +++ api/.eslintrc | 10 +++ client-final/.eslintrc | 10 +++ client/.eslintrc | 10 +++ .../__tests__/__snapshots__/editor.js.snap | 2 +- cypress-final/.eslintrc | 8 ++- cypress/.eslintrc | 4 +- cypress/e2e/users_spec.js | 1 + package-scripts.js | 12 ++-- package.json | 1 + templates/api/.eslintrc | 10 +++ templates/client/.eslintrc | 10 +++ templates/cypress/.eslintrc | 10 ++- templates/cypress/e2e/users_spec.js | 9 +++ yarn.lock | 27 +++++++- 17 files changed, 188 insertions(+), 12 deletions(-) create mode 100644 INSTRUCTIONS.md create mode 100644 api-final/.eslintrc create mode 100644 api/.eslintrc create mode 100644 client-final/.eslintrc create mode 100644 client/.eslintrc create mode 100644 templates/api/.eslintrc create mode 100644 templates/client/.eslintrc diff --git a/.gitignore b/.gitignore index a45d5885..809700d7 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ npm-debug.log* cypress/videos cypress/screenshots dist +.opt-in diff --git a/INSTRUCTIONS.md b/INSTRUCTIONS.md new file mode 100644 index 00000000..20c43c28 --- /dev/null +++ b/INSTRUCTIONS.md @@ -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 diff --git a/api-final/.eslintrc b/api-final/.eslintrc new file mode 100644 index 00000000..c38b649c --- /dev/null +++ b/api-final/.eslintrc @@ -0,0 +1,10 @@ +// FINAL_START +{ + "rules": { + "import/no-extraneous-dependencies": "off", + "import/no-unresolved": "off", + "no-unused-vars": "off", + + } +} +// FINAL_END \ No newline at end of file diff --git a/api/.eslintrc b/api/.eslintrc new file mode 100644 index 00000000..c38b649c --- /dev/null +++ b/api/.eslintrc @@ -0,0 +1,10 @@ +// FINAL_START +{ + "rules": { + "import/no-extraneous-dependencies": "off", + "import/no-unresolved": "off", + "no-unused-vars": "off", + + } +} +// FINAL_END \ No newline at end of file diff --git a/client-final/.eslintrc b/client-final/.eslintrc new file mode 100644 index 00000000..c38b649c --- /dev/null +++ b/client-final/.eslintrc @@ -0,0 +1,10 @@ +// FINAL_START +{ + "rules": { + "import/no-extraneous-dependencies": "off", + "import/no-unresolved": "off", + "no-unused-vars": "off", + + } +} +// FINAL_END \ No newline at end of file diff --git a/client/.eslintrc b/client/.eslintrc new file mode 100644 index 00000000..c38b649c --- /dev/null +++ b/client/.eslintrc @@ -0,0 +1,10 @@ +// FINAL_START +{ + "rules": { + "import/no-extraneous-dependencies": "off", + "import/no-unresolved": "off", + "no-unused-vars": "off", + + } +} +// FINAL_END \ No newline at end of file diff --git a/client/src/screens/__tests__/__snapshots__/editor.js.snap b/client/src/screens/__tests__/__snapshots__/editor.js.snap index 4825013b..5dfc3c39 100644 --- a/client/src/screens/__tests__/__snapshots__/editor.js.snap +++ b/client/src/screens/__tests__/__snapshots__/editor.js.snap @@ -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="" /> diff --git a/cypress-final/.eslintrc b/cypress-final/.eslintrc index a737fb32..d8f437f5 100644 --- a/cypress-final/.eslintrc +++ b/cypress-final/.eslintrc @@ -2,5 +2,11 @@ "globals": { "cy": false, "Cypress": false, + }, + "rules": { + "import/no-extraneous-dependencies": "off", + "import/no-unresolved": "off", + "no-unused-vars": "off", + } -} \ No newline at end of file +} diff --git a/cypress/.eslintrc b/cypress/.eslintrc index a737fb32..b3050092 100644 --- a/cypress/.eslintrc +++ b/cypress/.eslintrc @@ -2,5 +2,5 @@ "globals": { "cy": false, "Cypress": false, - } -} \ No newline at end of file + }, +} diff --git a/cypress/e2e/users_spec.js b/cypress/e2e/users_spec.js index eb6de5d6..bfb5fe1a 100644 --- a/cypress/e2e/users_spec.js +++ b/cypress/e2e/users_spec.js @@ -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? diff --git a/package-scripts.js b/package-scripts.js index 198c0ad7..3d61b1e0 100644 --- a/package-scripts.js +++ b/package-scripts.js @@ -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: { diff --git a/package.json b/package.json index 8a5142ad..ffc20020 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/templates/api/.eslintrc b/templates/api/.eslintrc new file mode 100644 index 00000000..c38b649c --- /dev/null +++ b/templates/api/.eslintrc @@ -0,0 +1,10 @@ +// FINAL_START +{ + "rules": { + "import/no-extraneous-dependencies": "off", + "import/no-unresolved": "off", + "no-unused-vars": "off", + + } +} +// FINAL_END \ No newline at end of file diff --git a/templates/client/.eslintrc b/templates/client/.eslintrc new file mode 100644 index 00000000..c38b649c --- /dev/null +++ b/templates/client/.eslintrc @@ -0,0 +1,10 @@ +// FINAL_START +{ + "rules": { + "import/no-extraneous-dependencies": "off", + "import/no-unresolved": "off", + "no-unused-vars": "off", + + } +} +// FINAL_END \ No newline at end of file diff --git a/templates/cypress/.eslintrc b/templates/cypress/.eslintrc index a737fb32..3442015b 100644 --- a/templates/cypress/.eslintrc +++ b/templates/cypress/.eslintrc @@ -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", + } -} \ No newline at end of file + // FINAL_END +} diff --git a/templates/cypress/e2e/users_spec.js b/templates/cypress/e2e/users_spec.js index 3ac41e73..55e1fa91 100644 --- a/templates/cypress/e2e/users_spec.js +++ b/templates/cypress/e2e/users_spec.js @@ -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' diff --git a/yarn.lock b/yarn.lock index af2f7227..ed2960ab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1152,7 +1152,7 @@ commander@2.6.0: 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: @@ -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" @@ -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" +lodash.clone@4.3.2: + 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" @@ -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" @@ -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" @@ -3938,6 +3957,10 @@ spawn-command-with-kill@^1.0.0: ps-tree "^1.1.0" spawn-command "^0.0.2-1" +spawn-command@0.0.2-1: + 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"