Skip to content

Commit f304033

Browse files
bors[bot]TheLaw1337bidoubiwa
authored
Merge #434
434: Setting up the Cypress with first test r=bidoubiwa a=TheLaw1337 Co-authored-by: Daniel Sobczak <[email protected]> Co-authored-by: cvermand <[email protected]>
2 parents 2d1f69d + a9348c4 commit f304033

File tree

7 files changed

+7618
-6840
lines changed

7 files changed

+7618
-6840
lines changed

.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ node_modules/
66
assets
77
.github
88
scripts
9+
cypress/screenshots
10+
cypress/videos
11+
cypress/support
12+
cypress/plugins
13+
cypress/fixtures

.eslintrc.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
/* Using eslint-config-algolia */
22
/* eslint-disable import/no-commonjs */
33
module.exports = {
4-
extends: ['algolia', 'algolia/jest', 'plugin:prettier/recommended'],
5-
plugins: ['prettier'],
4+
extends: [
5+
'algolia',
6+
'algolia/jest',
7+
'plugin:prettier/recommended',
8+
'plugin:cypress/recommended',
9+
],
10+
plugins: ['prettier', 'cypress'],
611
rules: {
712
'no-console': 0,
813
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],

.github/workflows/cypress-run.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: cypress-run
2+
on: push
3+
jobs:
4+
cypress-run:
5+
runs-on: ubuntu-latest
6+
# Browser on which the tests are run
7+
container: cypress/browsers:node12.18.3-chrome87-ff82
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v2
11+
- name: Setup node
12+
uses: actions/setup-node@v1
13+
with:
14+
node-version: '12.x'
15+
- name: Install dependencies
16+
run: yarn
17+
- name: Browser tests
18+
uses: cypress-io/github-action@v2
19+
with:
20+
# Your starting script
21+
start: yarn start:test-headless
22+
# Creates and uploads GitHub artifacts in case of failure
23+
- uses: actions/upload-artifact@v1
24+
if: failure()
25+
with:
26+
name: cypress-screenshots
27+
path: cypress/screenshots
28+
- uses: actions/upload-artifact@v1
29+
if: failure()
30+
with:
31+
name: cypress-videos
32+
path: cypress/videos

cypress.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const HOST = `http://localhost:1234` // Please adjust to your own app port
2+
3+
describe(`My first test`, () => {
4+
before(() => {
5+
cy.visit(HOST) // Visit our app
6+
})
7+
8+
it('Should visit the dashboard', () => {
9+
cy.url().should('match', new RegExp(HOST)) // The current host URL
10+
})
11+
12+
it('Should check if the searchbar is visible', () => {
13+
cy.get('.searchbox').should('be.visible')
14+
})
15+
16+
it('Should check if autocomplete is visible during typing', () => {
17+
cy.get('#docs-searchbar-suggestion').type('Quick')
18+
cy.get('#meilisearch-autocomplete-listbox-0').should('be.visible')
19+
cy.get('div.dsb-suggestion:nth-child(1)') // the first entry should be "Quick start"
20+
.contains('Quick start')
21+
})
22+
})

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
"lint": "eslint .",
2222
"lint:fix": "eslint --fix .",
2323
"test": "./scripts/test",
24-
"test:watch": "./scripts/test-watch"
24+
"test:watch": "./scripts/test-watch",
25+
"start:test": "concurrently --kill-others -s first \"yarn playground\" \"cypress open\"",
26+
"start:test-headless": "concurrently --kill-others -s first \"yarn playground\" \"cypress run\""
2527
},
2628
"files": [
2729
"dist/"
@@ -39,10 +41,13 @@
3941
"babel-jest": "^27.0.2",
4042
"babel-loader": "^8.2.1",
4143
"babel-plugin-rewire": "^1.2.0",
44+
"concurrently": "^6.3.0",
4245
"cssnano": "^4.1.11",
46+
"cypress": "^8.5.0",
4347
"eslint": "^7.21.0",
4448
"eslint-config-algolia": "^16.0.0",
4549
"eslint-config-prettier": "^8.1.0",
50+
"eslint-plugin-cypress": "^2.12.1",
4651
"eslint-plugin-eslint-comments": "^3.2.0",
4752
"eslint-plugin-import": "^2.22.0",
4853
"eslint-plugin-jest": "^24.1.8",
@@ -58,7 +63,6 @@
5863
"webpack": "^5.53.0",
5964
"webpack-cli": "^4.8.0"
6065
},
61-
"peerDependencies": {},
6266
"dependencies": {
6367
"autocomplete.js": "^0.38.0",
6468
"hogan.js": "^3.0.2",

0 commit comments

Comments
 (0)