Skip to content

Commit 6159524

Browse files
committed
feat: init cypress
1 parent 46a0ae8 commit 6159524

File tree

10 files changed

+1120
-0
lines changed

10 files changed

+1120
-0
lines changed

.eslintrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ module.exports = {
4646
plugins: ['react'],
4747
rules,
4848
},
49+
{
50+
files: ['cypress/**/*.jsx', 'cypress/**/*.js'],
51+
plugins: ['cypress'],
52+
extends: ['plugin:cypress/recommended'],
53+
env: {
54+
'cypress/globals': true,
55+
},
56+
},
4957
{
5058
files: ['**/*.svelte'],
5159
plugins: ['svelte3'],

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@ package/*.scss
3030
package/*.svelte
3131
!package/postinstall.js
3232
dist/demo
33+
34+
35+
cypress/screenshots

cypress.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"video": false
3+
}

cypress/fixtures/example.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "hello@cypress.io",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/// <reference types="cypress" />
2+
3+
context('Core', () => {
4+
beforeEach(() => {
5+
cy.visit('../../../playground/core/');
6+
});
7+
8+
describe('Init', () => {
9+
it('Active class', () => {
10+
cy.get('.swiper-container').contains('Slide 3').should('have.class', 'swiper-slide-active');
11+
});
12+
13+
it('Prev class', () => {
14+
cy.get('.swiper-container').contains('Slide 2').should('have.class', 'swiper-slide-prev');
15+
});
16+
17+
it('Next class', () => {
18+
cy.get('.swiper-container').contains('Slide 4').should('have.class', 'swiper-slide-next');
19+
});
20+
21+
it('a11y', () => {
22+
cy.get('.swiper-container')
23+
.find('.swiper-slide')
24+
.should('have.attr', 'aria-role-description', 'slide');
25+
cy.get('.swiper-container').find('.swiper-slide').should('have.attr', 'role', 'group');
26+
// cy.get('.swiper-container').find('.swiper-slide').should('have.attr', 'aria-lalbel');
27+
});
28+
});
29+
30+
describe('Slide', () => {
31+
it('Should slide next on slide click', () => {
32+
cy.get('.swiper-slide-next').click();
33+
cy.get('.swiper-container').contains('Slide 3').should('have.class', 'swiper-slide-prev');
34+
cy.get('.swiper-container').contains('Slide 4').should('have.class', 'swiper-slide-active');
35+
cy.get('.swiper-container').contains('Slide 5').should('have.class', 'swiper-slide-next');
36+
});
37+
38+
it('Should slide prev on slide click', () => {
39+
cy.get('.swiper-slide-prev').click();
40+
cy.get('.swiper-container').contains('Slide 1').should('have.class', 'swiper-slide-prev');
41+
cy.get('.swiper-container').contains('Slide 2').should('have.class', 'swiper-slide-active');
42+
cy.get('.swiper-container').contains('Slide 3').should('have.class', 'swiper-slide-next');
43+
});
44+
45+
it('Should slide next', () => {
46+
cy.get('.swiper-button-next').click();
47+
cy.get('.swiper-container').contains('Slide 3').should('have.class', 'swiper-slide-prev');
48+
cy.get('.swiper-container').contains('Slide 4').should('have.class', 'swiper-slide-active');
49+
cy.get('.swiper-container').contains('Slide 5').should('have.class', 'swiper-slide-next');
50+
});
51+
52+
it('Should slide prev', () => {
53+
cy.get('.swiper-button-prev').click();
54+
cy.get('.swiper-container').contains('Slide 1').should('have.class', 'swiper-slide-prev');
55+
cy.get('.swiper-container').contains('Slide 2').should('have.class', 'swiper-slide-active');
56+
cy.get('.swiper-container').contains('Slide 3').should('have.class', 'swiper-slide-next');
57+
});
58+
});
59+
});

cypress/plugins/index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/// <reference types="cypress" />
2+
// ***********************************************************
3+
// This example plugins/index.js can be used to load plugins
4+
//
5+
// You can change the location of this file or turn off loading
6+
// the plugins file with the 'pluginsFile' configuration option.
7+
//
8+
// You can read more here:
9+
// https://on.cypress.io/plugins-guide
10+
// ***********************************************************
11+
12+
// This function is called when a project is opened or re-opened (e.g. due to
13+
// the project's config changing)
14+
15+
/**
16+
* @type {Cypress.PluginConfig}
17+
*/
18+
/* eslint-disable no-unused-vars */
19+
module.exports = (on, config) => {
20+
// `on` is used to hook into various events Cypress emits
21+
// `config` is the resolved Cypress config
22+
};

cypress/support/commands.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// ***********************************************
2+
// This example commands.js shows you how to
3+
// create various custom commands and overwrite
4+
// existing commands.
5+
//
6+
// For more comprehensive examples of custom
7+
// commands please read more here:
8+
// https://on.cypress.io/custom-commands
9+
// ***********************************************
10+
//
11+
//
12+
// -- This is a parent command --
13+
// Cypress.Commands.add("login", (email, password) => { ... })
14+
//
15+
//
16+
// -- This is a child command --
17+
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
18+
//
19+
//
20+
// -- This is a dual command --
21+
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
22+
//
23+
//
24+
// -- This will overwrite an existing command --
25+
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

cypress/support/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ***********************************************************
2+
// This example support/index.js is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands';
18+
19+
// Alternatively you can use CommonJS syntax:
20+
// require('./commands')

0 commit comments

Comments
 (0)