mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Add docs on writing e2e tests. Minor cleanup to README elsewhere
This commit is contained in:
137
README.md
137
README.md
@@ -61,14 +61,17 @@ Table of Contents
|
||||
- [Introduction to the technology](#introduction-to-the-technology)
|
||||
- [Requirements](#requirements)
|
||||
- [Installing](#installing)
|
||||
- [Configuring](#configuring)
|
||||
- [Configuring](#configuring)
|
||||
- [Running the app](#running-the-app)
|
||||
- [Running in production mode](#running-in-production-mode)
|
||||
- [Running in production mode](#running-in-production-mode)
|
||||
- [Deploy](#deploy)
|
||||
- [Running the application with Docker](#running-the-application-with-docker)
|
||||
- [Cleaning](#cleaning)
|
||||
- [Testing](#testing)
|
||||
- [Test a Pull Request](#test-a-pull-request)
|
||||
- [Unit Tests](#unit-tests)
|
||||
- [E2E Tests](#e2e-tests)
|
||||
- [Writing E2E Tests](#writing-e2e-tests)
|
||||
- [Documentation](#documentation)
|
||||
- [Other commands](#other-commands)
|
||||
- [Recommended Editors/IDEs](#recommended-editorsides)
|
||||
@@ -217,18 +220,50 @@ Place your tests in the same location of the application source code files that
|
||||
|
||||
and run: `yarn run test`
|
||||
|
||||
### E2E test
|
||||
### E2E Tests
|
||||
|
||||
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.
|
||||
|
||||
The test files can be found in the `./cypress/integration/` folder.
|
||||
|
||||
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.
|
||||
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).
|
||||
|
||||
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.
|
||||
|
||||
#### Writing E2E Tests
|
||||
|
||||
All E2E tests must be created under the `./cypress/integration/` folder, and must end in `.spec.ts`. Subfolders are allowed.
|
||||
|
||||
* The easiest way to start creating new tests is by running `ng e2e`. This builds the app and brings up Cypress.
|
||||
* From here, if you are editing an existing test file, you can either open it in your IDE or run it first to see what it already does.
|
||||
* To create a new test file, click `+ New Spec File`. Choose a meaningful name ending in `spec.ts` (Please make sure it ends in `.ts` so that it's a Typescript file, and not plain Javascript)
|
||||
* Start small. Add a basic `describe` and `it` which just [cy.visit](https://docs.cypress.io/api/commands/visit) the page you want to test. For example:
|
||||
```
|
||||
describe('Community/Collection Browse Page', () => {
|
||||
it('should exist as a page', () => {
|
||||
cy.visit('/community-list');
|
||||
});
|
||||
});
|
||||
```
|
||||
* Run your test file from the Cypress window. This starts the [Cypress Test Runner](https://docs.cypress.io/guides/core-concepts/test-runner) in a new browser window.
|
||||
* In the [Cypress Test Runner](https://docs.cypress.io/guides/core-concepts/test-runner), you'll Cypress automatically visit the page. This first test will succeed, as all you are doing is making sure the _page exists_.
|
||||
* From here, you can use the [Selector Playground](https://docs.cypress.io/guides/core-concepts/test-runner#Selector-Playground) in the Cypress Test Runner window to determine how to tell Cypress to interact with a specific HTML element on that page.
|
||||
* 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
|
||||
* 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.
|
||||
* Cypress can also validate that something occurs, using [should()](https://docs.cypress.io/api/commands/should) assertions.
|
||||
* 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.
|
||||
|
||||
|
||||
_Hint: Creating e2e tests is easiest in an IDE (like Visual Studio), as it can help prompt/autocomplete your Cypress commands._
|
||||
|
||||
More Information: [docs.cypress.io](https://docs.cypress.io/) has great guides & documentation helping you learn more about writing/debugging e2e tests in Cypress.
|
||||
|
||||
Documentation
|
||||
--------------
|
||||
|
||||
See [`./docs`](docs) for further documentation.
|
||||
Official DSpace documentation is available in the DSpace wiki at https://wiki.lyrasis.org/display/DSDOC7x/
|
||||
|
||||
Some UI specific configuration documentation is also found in the [`./docs`](docs) folder of htis codebase.
|
||||
|
||||
### Building code documentation
|
||||
|
||||
@@ -251,8 +286,6 @@ To get the most out of TypeScript, you'll need a TypeScript-aware editor. We've
|
||||
- Free
|
||||
- [Visual Studio Code](https://code.visualstudio.com/)
|
||||
- [Debugger for Chrome](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome)
|
||||
- [Atom](https://atom.io/)
|
||||
- [TypeScript plugin](https://atom.io/packages/atom-typescript)
|
||||
- Paid
|
||||
- [Webstorm](https://www.jetbrains.com/webstorm/download/) or [IntelliJ IDEA Ultimate](https://www.jetbrains.com/idea/)
|
||||
- [Sublime Text](http://www.sublimetext.com/3)
|
||||
@@ -274,95 +307,43 @@ dspace-angular
|
||||
│ ├── environment.default.js * Default configuration files
|
||||
│ └── environment.test.js * Test configuration files
|
||||
├── docs * Folder for documentation
|
||||
├── e2e * Folder for e2e test files
|
||||
│ ├── app.e2e-spec.ts *
|
||||
│ ├── app.po.ts *
|
||||
│ ├── pagenotfound *
|
||||
│ │ ├── pagenotfound.e2e-spec.ts *
|
||||
│ │ └── pagenotfound.po.ts *
|
||||
├── cypress * Folder for Cypress (https://cypress.io/) / e2e tests
|
||||
│ ├── integration * Folder for e2e/integration test files
|
||||
│ ├── fixtures * Folder for any fixtures needed by e2e tests
|
||||
│ ├── plugins * Folder for Cypress plugins (if any)
|
||||
│ ├── support * Folder for global e2e test actions/commands (run for all tests)
|
||||
│ └── tsconfig.json * TypeScript configuration file for e2e tests
|
||||
├── karma.conf.js * Karma configuration file for Unit Test
|
||||
├── nodemon.json * Nodemon (https://nodemon.io/) configuration
|
||||
├── package.json * This file describes the npm package for this project, its dependencies, scripts, etc.
|
||||
├── postcss.config.js * PostCSS (http://postcss.org/) configuration file
|
||||
├── protractor.conf.js *
|
||||
├── resources * Folder for static resources
|
||||
│ ├── data * Folder for static data
|
||||
│ │ └── en * Folder for i18n English data
|
||||
│ ├── i18n * Folder for i18n translations
|
||||
│ │ └── en.json * i18n translations for English
|
||||
│ └── images * Folder for images
|
||||
│ ├── dspace-logo-old.png *
|
||||
│ ├── dspace-logo.png *
|
||||
│ └── favicon.ico *
|
||||
├── rollup.config.js * Rollup (http://rollupjs.org/) configuration
|
||||
├── spec-bundle.js *
|
||||
├── src * The source of the application
|
||||
│ ├── app *
|
||||
│ │ ├── app-routing.module.ts *
|
||||
│ │ ├── app.component.html *
|
||||
│ │ ├── app.component.scss *
|
||||
│ │ ├── app.component.spec.ts *
|
||||
│ │ ├── app.component.ts *
|
||||
│ │ ├── app.effects.ts *
|
||||
│ │ ├── app.module.ts *
|
||||
│ │ ├── app.reducer.ts *
|
||||
│ │ ├── browser-app.module.ts * The root module for the client
|
||||
│ │ ├── +collection-page * Lazily loaded route for collection module
|
||||
│ │ ├── +community-page * Lazily loaded route for community module
|
||||
│ │ ├── core *
|
||||
│ │ ├── header *
|
||||
│ │ ├── +home * Lazily loaded route for home module
|
||||
│ │ ├── +item-page * Lazily loaded route for item module
|
||||
│ │ ├── object-list *
|
||||
│ │ ├── pagenotfound *
|
||||
│ │ ├── server-app.module.ts * The root module for the server
|
||||
│ │ ├── shared *
|
||||
│ │ ├── store.actions.ts *
|
||||
│ │ ├── store.effects.ts *
|
||||
│ │ ├── thumbnail *
|
||||
│ │ └── typings.d.ts * File that allows you to add custom typings for libraries without TypeScript support
|
||||
│ ├── app * The source code of the application, subdivided by module/page.
|
||||
│ ├── assets * Folder for static resources
|
||||
│ │ ├── fonts * Folder for fonts
|
||||
│ │ ├── i18n * Folder for i18n translations
|
||||
│ | └── en.json5 * i18n translations for English
|
||||
│ │ └── images * Folder for images
|
||||
│ ├── backend * Folder containing a mock of the REST API, hosted by the express server
|
||||
│ │ ├── api.ts *
|
||||
│ │ ├── cache.ts *
|
||||
│ │ ├── data *
|
||||
│ │ └── db.ts *
|
||||
│ ├── config *
|
||||
│ │ ├── cache-config.interface.ts *
|
||||
│ │ ├── config.interface.ts *
|
||||
│ │ ├── global-config.interface.ts *
|
||||
│ │ ├── server-config.interface.ts *
|
||||
│ │ └── universal-config.interface.ts *
|
||||
│ ├── config.ts * File that loads environmental and shareable settings and makes them available to app components
|
||||
│ ├── index.csr.html * The index file for client side rendering fallback
|
||||
│ ├── index.html * The index file
|
||||
│ ├── main.browser.ts * The bootstrap file for the client
|
||||
│ ├── main.server.ts * The express (http://expressjs.com/) config and bootstrap file for the server
|
||||
│ ├── robots.txt * The robots.txt file
|
||||
│ ├── modules *
|
||||
│ │ ├── cookies *
|
||||
│ │ ├── data-loader *
|
||||
│ │ ├── transfer-http *
|
||||
│ │ ├── transfer-state *
|
||||
│ │ ├── transfer-store *
|
||||
│ │ └── translate-universal-loader.ts *
|
||||
│ ├── routes.ts * The routes file for the server
|
||||
│ ├── styles * Folder containing global styles
|
||||
│ │ ├── _mixins.scss *
|
||||
│ │ └── variables.scss * Global sass variables file
|
||||
│ ├── tsconfig.browser.json * TypeScript config for the client build
|
||||
│ ├── tsconfig.server.json * TypeScript config for the server build
|
||||
│ └── tsconfig.test.json * TypeScript config for the test build
|
||||
│ └── themes * Folder containing available themes
|
||||
│ ├── custom * Template folder for creating a custom theme
|
||||
│ └── dspace * Default 'dspace' theme
|
||||
├── tsconfig.json * TypeScript config
|
||||
├── tslint.json * TSLint (https://palantir.github.io/tslint/) configuration
|
||||
├── typedoc.json * TYPEDOC configuration
|
||||
├── webpack * Webpack (https://webpack.github.io/) config directory
|
||||
│ ├── webpack.aot.js * Webpack (https://webpack.github.io/) config for AoT build
|
||||
│ ├── webpack.client.js * Webpack (https://webpack.github.io/) config for client build
|
||||
│ ├── webpack.common.js *
|
||||
│ ├── webpack.prod.js * Webpack (https://webpack.github.io/) config for production build
|
||||
│ ├── webpack.server.js * Webpack (https://webpack.github.io/) config for server build
|
||||
│ └── webpack.test.js * Webpack (https://webpack.github.io/) config for test build
|
||||
├── webpack.config.ts *
|
||||
│ ├── webpack.browser.ts * Webpack (https://webpack.github.io/) config for client build
|
||||
│ ├── webpack.common.ts *
|
||||
│ ├── webpack.prod.ts * Webpack (https://webpack.github.io/) config for production build
|
||||
│ └── webpack.test.ts * Webpack (https://webpack.github.io/) config for test build
|
||||
└── yarn.lock * Yarn lockfile (https://yarnpkg.com/en/docs/yarn-lock)
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user