From c68d84e2f9fb8f0b9ac655aef7830f3f8af8e908 Mon Sep 17 00:00:00 2001 From: gregdyke Date: Sat, 3 Jul 2021 03:15:16 +0100 Subject: [PATCH 1/2] describe tests in README; use jest projects --- README.md | 20 ++++++++++++++++++++ package.json | 15 ++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5833a402f..3beb05bc2 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,26 @@ The exercises are split into three folders: `exercises`, `mandatory` and `extra` The `extra` folder contains exercises that you can complete to challenge yourself, but are not required for the following lesson. +## Running the code/tests + +These files for the mandatory/extra exercises are intended to be run as jest tests. + +- Once you have cloned the repository, run `npm install` once in the terminal to install jest (and any necessary dependencies). +- To run the tests for all mandatory/extra exercises, run `npm test` +- To run only the tests for the mandatory exercises, run `npm test -- --selectProjects mandatory` +- To run only the tests for the extra exercises, run `npm test -- --selectProjects extra` +- To run a single exercise/test (for example `mandatory/1-writer.js`), run `npm test -- --testPathPattern mandatory/1-writer.js` (Remember, you can use tab-completion to get files relative to the current directory, so m`Tab ↹`/1-`Tab ↹` will autocomplete get you the test file starting with 1-) + +For more information about tests, look here: + +https://syllabus.codeyourfuture.io/guides/intro-to-tests + +Try out variant way of running tests: + +- `npm test` -> run all mandatory and extra tests +- `npm test -- --selectProjects mandatory` -> run only mandatory tests +- `npm test -- --testPathPattern mandatory/1-syntax-errors.js` -> run single test + ## Solutions The solutions for this coursework can be found here: diff --git a/package.json b/package.json index 58555936d..20667ac4f 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,7 @@ "version": "1.0.0", "description": "Exercises for JS1 Week 1", "scripts": { - "test": "jest --testRegex='mandatory[/\\\\].*\\.js$'", - "extra-tests": "jest --testRegex='extra[/\\\\].*\\.js$'" + "test": "jest" }, "repository": { "type": "git", @@ -14,7 +13,17 @@ "url": "https://github.com/CodeYourFuture/JavaScript-Core-1-Coursework-Week1/issues" }, "jest": { - "setupFilesAfterEnv": ["jest-extended"] + "setupFilesAfterEnv": ["jest-extended"], + "projects": [ + { + "displayName": "mandatory", + "testMatch": ["/mandatory/*.js"] + }, + { + "displayName": "extra", + "testMatch": ["/extra/*.js"] + } + ] }, "homepage": "https://github.com/CodeYourFuture/JavaScript-Core-1-Coursework-Week1#readme", "devDependencies": { From 725bfdaf7a1b83678c52ac78076d7fc98aa6d14f Mon Sep 17 00:00:00 2001 From: Sally McGrath <42203406+SallyMcGrath@users.noreply.github.com> Date: Mon, 6 Sep 2021 16:34:53 +0100 Subject: [PATCH 2/2] Update README.md spag Co-authored-by: Alasdair Smith --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3beb05bc2..dff05d7cd 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ The `extra` folder contains exercises that you can complete to challenge yoursel ## Running the code/tests -These files for the mandatory/extra exercises are intended to be run as jest tests. +The files for the mandatory/extra exercises are intended to be run as jest tests. - Once you have cloned the repository, run `npm install` once in the terminal to install jest (and any necessary dependencies). - To run the tests for all mandatory/extra exercises, run `npm test`