Skip to content
Permalink
Browse files
updated notes on setup
  • Loading branch information
aa7401 committed Nov 20, 2018
1 parent b364832 commit f2863900cb6251beb5a307e2c47663c94b78d6af
Showing 1 changed file with 23 additions and 13 deletions.
@@ -67,26 +67,36 @@ lets install, configure and run the console-based linter.
This week you are starting the development process. You are advised to use the `koa` framework rather than `express` or `restify`. Follow the steps listed below. You can find examples of all the files in the TEACHING-MATERIALS repository:

1. Ensure you have private repo(s) in the 340CT-1819OCTJAN organisation (where the TEACHING-MATERIALS repo is found). Names should be in the format xxx-yyy where xxx is your university username. Clone this into your chosen IDE.
2. Create a package.json file by running the `npm init` command.
3. Install any packages needed by your script using the `npm install --save xxx` command, where xxx is the package name. Make sure this has added the package to your `package.json` file.
4. Install any developer tools (such as eslint and jest) using the `npm install --save-dev xxx` command. This will add the module to the `dev-dependency` section of your `package.json` file.
5. Set up your `.eslintrc.json` file with the rules you want to use.
6. Add a `.eslintignore` file containing the files and directories you want to be ignored by the linter.
7. Add a jest section to your `package.json` that includes the coverage thresholds you are aiming for (100%).
8. Create a `pre-commit` hook:
2. Create a `.gitignore` file in the root of your repository and add the files and directories you _don't_ want git to add to the repository. Use the example in this repository as a starting point.
3. Create a package.json file by running the `npm init` command.
4. Install any packages needed by your script using the `npm install --save xxx` command, where xxx is the package name. Make sure this has added the package to your `package.json` file.
5. Install any developer tools (such as eslint and jest) using the `npm install --save-dev xxx` command. This will add the module to the `dev-dependency` section of your `package.json` file.
6. Set up your `.eslintrc.json` file with the rules you want to use.
7. Add a `.eslintignore` file containing the files and directories you want to be ignored by the linter.
8. Add a jest section to your `package.json` that includes the coverage thresholds you are aiming for (100%).
9. Create a `pre-commit` hook:
1. Create a `.githooks` directory in the root of your project.
2. Create a `pre-commit` file in this new directory and add:
1. A _shebang_. If you are on Windows this will be `#!C:/Program\ Files/Git/usr/bin/sh.exe`, on Mac or Linux it is `#!/bin/sh`.
2. the line `echo "pre-commit hook working"`.
3. Save the changes in the file and make sure it is executable.
4. Set your hooksPath configuration variable to point to your new directory: `git config core.hooksPath .githooks`
5. Stage and commit this new file using the git CLI. When you commit the changes yu should see the message `pre-commit hook working`, this indicates the hook is being triggered correctly.
9. Create a `README.md` file and add the name of your project.
10. Stage and commit the file using the terminal commands:
10. Create a `README.md` file and add the name of your project.
11. Stage and commit the file using the terminal commands:
1. You should see the message `pre-commit hook working` in the terminal.
11. Create a `pre-push` hook file and add a suitable message. Test it is working.
12. Start developing your code. Make sure you apply TDD (write a test to define your next piece of functionality before implementing).
13. Modify the `pre-commit` hook to run the linter.
14. Modify the `pre-push` hook to run the jest test suite with code coverage.
12. Create a `pre-push` hook file and add a suitable message. Test it is working.
13. Start developing your code. Make sure you apply TDD (write a test to define your next piece of functionality before implementing).
14. Modify the `pre-commit` hook to run the linter.
15. Modify the `pre-push` hook to run the jest test suite with code coverage.

### 2.1 Preparing for Test-Driven Development
At this stage you can start building your system. Each time you commit code the linter will run. Each time you push your code it will run the unit tests.

Every time you add a new `.js` file to your code you should:

1. Create a matching test file using the format `xxx.test.js`.
2. Import the test frameworks and your js file into the test suite.
3. Run the test suites and check that it is picking up the new test suite.

As you write the code, keep the test running going using watch mode. This means that every time you save a file the entire test suite will run. Keep an eye on the code coverage and make sure it **never drops below 100%**.

0 comments on commit f286390

Please sign in to comment.