Skip to content

add Cypress component tests#1

Open
bahmutov wants to merge 1 commit intoleveluptuts:masterfrom
bahmutov:add-component-testing
Open

add Cypress component tests#1
bahmutov wants to merge 1 commit intoleveluptuts:masterfrom
bahmutov:add-component-testing

Conversation

@bahmutov
Copy link

@bahmutov bahmutov commented May 8, 2020

Tests are using Cypress + https://github.com/bahmutov/cypress-svelte-unit-test

Example

import Code from './Code.svelte'
import { mount } from 'cypress-svelte-unit-test'

describe('Code', () => {
  it('has syntax highlighting', () => {
    mount(Code, {
      props: {
        lang: 'js',
        code: '// this is a component test\n' + 'const cy = "Cypress"',
      },
    })
    cy.contains('.hljs-comment', '// this is a component test')
    cy.contains('.hljs-keyword', 'const')
  })
})

Screen Shot 2020-05-08 at 5 57 50 PM

Similarly, the Notion component test

Screen Shot 2020-05-08 at 6 06 27 PM

PS: hmm, seems Prettier and ESLint are fighting over style issues, as I was trying to fix one, the other one was breaking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant