Skip to content

Commit

Permalink
SFINT-2878 Added Cypress functional tests (#60)
Browse files Browse the repository at this point in the history
* test(SFINT-2878): Add Cypress base setup

* test(SFINT-2878): Add dummy test

* chore(SFINT-2878): Switch cypress to typescript
  • Loading branch information
jeremierobert-coveo authored Feb 25, 2020
1 parent fd0ceb0 commit 1b49530
Show file tree
Hide file tree
Showing 10 changed files with 3,835 additions and 56 deletions.
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,29 @@ node_js:
- lts/*
addons:
chrome: stable
apt:
packages:
# Ubuntu 16+ does not install this dependency by default, so we need to install it ourselves
- libgconf-2-4
notifications:
email:
on_success: change
on_failure: always
cache:
# Caches $HOME/.npm when npm ci is default script command
# Caches node_modules in all other cases
npm: true
directories:
# we also need to cache folder with Cypress binary
- ~/.cache
install:
- npm ci
script:
- npm run lint
- npm run build
- npm run testCoverage
- npm run dev & npx wait-on http://localhost:8080
- npx cypress run
before_deploy:
- node ./scripts/before.deploy.js
deploy:
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,18 @@ The code is written in [typescript](http://www.typescriptlang.org/) and compiled

## Dev

`npm run dev` will start a [webpack dev server](https://webpack.github.io/docs/webpack-dev-server.html). After it finishes, load [http://localhost:8080/index.html](http://localhost:8080/pages/index.html) in a browser, and the `index.html` page should load.
`npm run dev` will start a [webpack dev server](https://webpack.github.io/docs/webpack-dev-server.html). After it finishes, load [http://localhost:8080/pages/attached_result.html](http://localhost:8080/pages/attached_result.html) in a browser, and the `index.html` page should load.

Then, anytime you hit save in a typescript file, the server will reload your application.

## Tests

- `npm run test` will execute the tests one time and give you the report
- `npm run watchTest` will watch changes and reexecute the tests and coverage when saving a file.

## Running functional tests

1. `npm run dev` will start the developer server.
2. `npx cypress run` will run the cypress functional tests suite.

To add a new test suite simply add a new spec file in the `./cypress/integration/` folder.
11 changes: 11 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"baseUrl": "http://localhost:8080",
"reporter": "spec",
"viewportHeight": 1080,
"viewportWidth": 1920,
"reporterOptions": {
"toConsole": true
},
"chromeWebSecurity": false,
"video": false
}
5 changes: 5 additions & 0 deletions cypress/integration/basic.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('Basic', () => {
it('should run an assertion', () => {
expect(true).to.be.true;
});
});
3 changes: 3 additions & 0 deletions cypress/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"include": ["../node_modules/cypress", "./**/*.js"]
}
20 changes: 20 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const wp = require('@cypress/webpack-preprocessor');
module.exports = on => {
const options = {
webpackOptions: {
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: { transpileOnly: true }
}
]
}
}
};
on('file:preprocessor', wp(options));
};
10 changes: 10 additions & 0 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"strict": true,
"baseUrl": "../node_modules",
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "mocha", "chai"]
},
"include": ["**/*.ts"]
}
Loading

0 comments on commit 1b49530

Please # to comment.