solidjs / solid-testing-library

Simple and complete Solid testing utilities that encourage good testing practices.
MIT License
201 stars 19 forks source link

new location option to setup router #40

Closed atk closed 1 year ago

atk commented 1 year ago

A common use case is to test an app that requires a predefined router for different paths. To make the setup more convenient, this comes with a new location option that makes render setup a router and navigate to the location.

Minoo7 commented 7 months ago

This does not work for me.

  it('can render a route with the id', async () => {
    const { findByText } = render(() => <App />, { location: '/ids/1234' })
    expect(await findByText('Id: 1234')).not.toBeFalsy()
  })

Gives:

   FAIL  src/test/pages/Drone-view.test.tsx > location option > can render a route with the id
TestingLibraryElementError: Unable to find an element with the text: Id: 1234. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.
paularmstrong commented 7 months ago

Related: https://github.com/solidjs/solid-testing-library/issues/60#issuecomment-2054228917