Commits
Tim Donohue authored 523fca2177f
205 205 | 2. `yarn run clean` (This resets your local dependencies to ensure you are up-to-date with this PR) |
206 206 | 3. `yarn install` (Updates your local dependencies to those in the PR) |
207 207 | 4. `yarn start` (Rebuilds the project, and deploys to localhost:4000, by default) |
208 208 | 5. At this point, the code from the PR will be deployed to http://localhost:4000. Test it out, and ensure that it does what is described in the PR (or fixes the bug described in the ticket linked to the PR). |
209 209 | |
210 210 | Once you have tested the Pull Request, please add a comment and/or approval to the PR to let us know whether you found it to be successful (or not). Thanks! |
211 211 | |
212 212 | |
213 213 | ### Unit Tests |
214 214 | |
215 - | Unit tests use Karma. You can find the configuration file at the same level of this README file:`./karma.conf.js` If you are going to use a remote test environment you need to edit the `./karma.conf.js`. Follow the instructions you will find inside it. To executing tests whenever any file changes you can modify the 'autoWatch' option to 'true' and 'singleRun' option to 'false'. A coverage report is also available at: http://localhost:9876/ after you run: `yarn run coverage`. |
215 + | Unit tests use the [Jasmine test framework](https://jasmine.github.io/), and are run via [Karma](https://karma-runner.github.io/). |
216 + | |
217 + | You can find the Karma configuration file at the same level of this README file:`./karma.conf.js` If you are going to use a remote test environment you need to edit the `./karma.conf.js`. Follow the instructions you will find inside it. To executing tests whenever any file changes you can modify the 'autoWatch' option to 'true' and 'singleRun' option to 'false'. A coverage report is also available at: http://localhost:9876/ after you run: `yarn run coverage`. |
216 218 | |
217 219 | The default browser is Google Chrome. |
218 220 | |
219 - | Place your tests in the same location of the application source code files that they test. |
221 + | Place your tests in the same location of the application source code files that they test, e.g. ending with `*.component.spec.ts` |
222 + | |
223 + | and run: `yarn test` |
220 224 | |
221 - | and run: `yarn run test` |
225 + | If you run into odd test errors, see the Angular guide to debugging tests: https://angular.io/guide/test-debugging |
222 226 | |
223 227 | ### E2E Tests |
224 228 | |
225 229 | E2E tests (aka integration tests) use [Cypress.io](https://www.cypress.io/). Configuration for cypress can be found in the `cypress.json` file in the root directory. |
226 230 | |
227 231 | The test files can be found in the `./cypress/integration/` folder. |
228 232 | |
229 233 | Before you can run e2e tests, you MUST have a running backend (i.e. REST API). By default, the e2e tests look for this at http://localhost:8080/server/ or whatever `rest` backend is defined in your `environment.prod.ts` or `environment.common.ts`. You may override this using env variables, see [Configuring](#configuring). |
230 234 | |
231 235 | Run `ng e2e` to kick off the tests. This will start Cypress and allow you to select the browser you wish to use, as well as whether you wish to run all tests or an individual test file. Once you click run on test(s), this opens the [Cypress Test Runner](https://docs.cypress.io/guides/core-concepts/test-runner) to run your test(s) and show you the results. |
251 255 | * Most commands start by telling Cypress to [get()](https://docs.cypress.io/api/commands/get) a specific element, using a CSS or jQuery style selector |
252 256 | * Cypress can then do actions like [click()](https://docs.cypress.io/api/commands/click) an element, or [type()](https://docs.cypress.io/api/commands/type) text in an input field, etc. |
253 257 | * Cypress can also validate that something occurs, using [should()](https://docs.cypress.io/api/commands/should) assertions. |
254 258 | * Any time you save your test file, the Cypress Test Runner will reload & rerun it. This allows you can see your results quickly as you write the tests & correct any broken tests rapidly. |
255 259 | * Cypress also has a great guide on [writing your first test](https://on.cypress.io/writing-first-test) with much more info. Keep in mind, while the examples in the Cypress docs often involve Javascript files (.js), the same examples will work in our Typescript (.ts) e2e tests. |
256 260 | |
257 261 | _Hint: Creating e2e tests is easiest in an IDE (like Visual Studio), as it can help prompt/autocomplete your Cypress commands._ |
258 262 | |
259 263 | More Information: [docs.cypress.io](https://docs.cypress.io/) has great guides & documentation helping you learn more about writing/debugging e2e tests in Cypress. |
260 264 | |
265 + | ### Learning how to build tests |
266 + | |
267 + | See our [DSpace Code Testing Guide](https://wiki.lyrasis.org/display/DSPACE/Code+Testing+Guide) for more hints/tips. |
268 + | |
261 269 | Documentation |
262 270 | -------------- |
263 271 | |
264 272 | Official DSpace documentation is available in the DSpace wiki at https://wiki.lyrasis.org/display/DSDOC7x/ |
265 273 | |
266 274 | Some UI specific configuration documentation is also found in the [`./docs`](docs) folder of htis codebase. |
267 275 | |
268 276 | ### Building code documentation |
269 277 | |
270 278 | To build the code documentation we use [TYPEDOC](http://typedoc.org). TYPEDOC is a documentation generator for TypeScript projects. It extracts information from properly formatted comments that can be written within the code files. Follow the instructions [here](http://typedoc.org/guides/doccomments/) to know how to make those comments. |