Files
cypress/npm/react/cypress/component/basic/before-hook
Dmitriy Kovalenko 9c642369fc chore(component-testing): Remove useless code & deps in @cypress/react and @cypress/vue (#15113)
* Remove useless code

* Add code-coverage to reacr devDependencies

* Remove react/support imports

* Remove some useless code from @cypress/react

* Cleanup vue

* Make it works :)

* Fix react errors

* Fix next.js react example

Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
Co-authored-by: Barthélémy Ledoux <bart@cypress.io>
2021-02-19 14:58:40 -06:00
..

example: mount the component inside before hook

Typically we advise to mount the component inside the test or inside the beforeEach hook

// mount the component inside the test
it('does something', () => {
  mount(...)
})
// mount the component before each test
describe('component', () => {
  beforeEach(() => {
    mount(...)
  })
  it('works 1', () => {
    ...
  })
  it('works 2', () => {
    ...
  })
})

This example shows that we can mount the component once and then run tests against it

before(() => {
  mount(...)
})
it('works 1', () => {
  ...
})
it('works 2', () => {
  ...
})

See spec.js