Skip to content
This repository was archived by the owner on Mar 5, 2022. It is now read-only.
This repository was archived by the owner on Mar 5, 2022. It is now read-only.

cannot find root element to mount the component #282

@SteveSchreiner

Description

@SteveSchreiner

Hi,

We have a react app with nextjs and get the following error when trying to run a test.

The waitForReact(10000, '#__next') passes but the test fails on mounting with a cant find rootId error. I looked in the source and it expect rootId to equal 'cypress-root' ?

https://github.com/bahmutov/cypress-react-unit-test/blob/master/lib/index.ts

`
import React from "react"
import Header from "./Header"
import {mount} from 'cypress-react-unit-test'

describe('Header', () => {
before(() => {
cy.visit('http://localhost:3000');
cy.waitForReact(10000, '#__next');
})
it('ToDO', () => {
mount(

)
})
})
`

This is our support/index.js file:

`// ***********************************************************
// This example support/index.js 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'
import 'cypress-react-selector'

require('cypress-react-unit-test/support')

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

image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions