Skip to content

Commit

Permalink
Merge pull request #252 from edx/matthugs/document-local-test-debugging
Browse files Browse the repository at this point in the history
docs(testDebugging): Document debugging tests within container
  • Loading branch information
matthugs authored Sep 25, 2018
2 parents d5273a1 + 7014379 commit 313acc3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ built by your local checkout.

### Where do test files go?
If you are developing a component and you are adding new `js` or `jsx` test files,
the test files would go in the same location as the file. It makes it easier
to track and test. For example, if you are developing a component `AssertsSearch`
the test files would go in the same location as the file. This makes it easier
to track and test. For example, if you are developing a component `AssetsSearch`
in `src/components/` you would name the test file after the component name
`AssertsSearch.test.jsx`. Similarly, if you are adding a file
`AssetsSearch.test.jsx`. Similarly, if you are adding a file
`parseDateTime.jsx` in the `src/utils/` place the test file at same location with
the name `parseDateTime.test.jsx`.

Expand All @@ -121,6 +121,20 @@ You can also add `".only"` to any `"it"` or `"describe"` block in a particular t
file to only run that particular test. For example, `it.only` to run only that test
or `describe.only` to run only the tests in that describe block.

### How to debug locally running tests
To debug tests running locally, first open the Node debugger:

1) navigate to `chrome://inspect` in your browser
2) choose "Open dedicated DevTools for Node" (it will open in a new window)
3) check that the default network configuration in the "Connection" tab is `127.0.0.1:9229` (i.e. port `9229` on `localhost`)

Next, after adding a `debugger;` statement above the test code you'd like to debug, use these commands inside the `studio-frontend` repo:
```
make shell
node --inspect=0.0.0.0 node_modules/.bin/jest --runInBand
```
The node debugger should grab focus as soon as your first breakpoint is hit. You can specify individual test files by appending `-- path/to/yourTestFile.test.jsx` to the end of the `node` command.

## Testing a Branch on a Sandbox

It is a good practice to test out any major changes to studio-frontend in a
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
- container_only_node_modules:/studio-frontend/node_modules
ports:
- "18011:18011"
- "9229:9229"

networks:
default:
Expand Down

0 comments on commit 313acc3

Please sign in to comment.