Skip to content

Commit

Permalink
Merge pull request #24 from oaoong/feat-test
Browse files Browse the repository at this point in the history
🧪 add e2e test
  • Loading branch information
oaoong authored Mar 1, 2024
2 parents 893aaf0 + b792238 commit 041d58b
Show file tree
Hide file tree
Showing 33 changed files with 728 additions and 2,288 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = {
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:cypress/recommended',
'prettier',
],
plugins: ['@typescript-eslint', 'import', 'react', 'react-hooks'],
Expand All @@ -32,6 +33,13 @@ module.exports = {
location: 'anywhere',
},
],
'no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
curly: ['error', 'all'],
eqeqeq: ['error', 'always', { null: 'ignore' }],
'@typescript-eslint/naming-convention': [
Expand Down
7 changes: 7 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'cypress'

export default defineConfig({
e2e: {
baseUrl: 'http://localhost:6006', // Storybook URL
},
})
26 changes: 26 additions & 0 deletions cypress/e2e/misty.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
describe('Misty Component Tests', () => {
it('Normal Story', () => {
cy.visit('/iframe.html?args=&viewMode=story&id=ui-misty--normal')
cy.get('[data-cy=misty-body]').should('be.visible')
cy.get('[data-cy=misty-contents]').should('not.exist')
cy.get('[data-cy=misty-close_button]').contains('X').click()
cy.get('[data-cy=misty-contents]').should('be.visible')
cy.get('[data-cy=misty-body]').should('not.exist')
})

it('Preload Story', () => {
cy.visit('/iframe.html?args=&viewMode=story&id=ui-misty--preload')
cy.get('[data-cy=misty-body]').should('be.visible')
cy.get('[data-cy=misty-contents]').should('exist')
cy.get('[data-cy=misty-contents]').should('not.be.visible')
cy.get('[data-cy=misty-close_button]').contains('X').click()
cy.get('[data-cy=misty-contents]').should('be.visible')
cy.get('[data-cy=misty-body]').should('exist')
})

it('Verified Story', () => {
cy.visit('/iframe.html?args=&viewMode=story&id=ui-misty--verified')
cy.get('[data-cy=misty-contents]').should('be.visible')
cy.get('[data-cy=misty-body]').should('not.exist')
})
})
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
37 changes: 37 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
27 changes: 27 additions & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')

Cypress.on('uncaught:exception', (err, _runnable) => {
if (err.message.includes('ResizeObserver loop completed with undelivered notifications.')) {
// ignore the error
return false
}
})
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oaoong/misty",
"version": "0.2.3",
"version": "1.0.0",
"description": "make component misty",
"repository": {
"type": "git",
Expand All @@ -22,6 +22,7 @@
"build": "rollup -c rollup.config.mjs",
"build-clean": "eslint . && rd /s/q dist 2> nul && rollup -c rollup.config.mjs",
"test": "vitest --run",
"cypress": "cypress open",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"lint": "eslint .",
Expand Down Expand Up @@ -51,8 +52,10 @@
"@typescript-eslint/parser": "^6.19.0",
"chromatic": "^10.3.0",
"css-loader": "^6.9.0",
"cypress": "^13.6.6",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-cypress": "^2.15.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
Expand Down
18 changes: 0 additions & 18 deletions playgrounds/vite-react-ts/.eslintrc.cjs

This file was deleted.

24 changes: 0 additions & 24 deletions playgrounds/vite-react-ts/.gitignore

This file was deleted.

30 changes: 0 additions & 30 deletions playgrounds/vite-react-ts/README.md

This file was deleted.

13 changes: 0 additions & 13 deletions playgrounds/vite-react-ts/index.html

This file was deleted.

28 changes: 0 additions & 28 deletions playgrounds/vite-react-ts/package.json

This file was deleted.

Loading

0 comments on commit 041d58b

Please sign in to comment.