category: packages
ui-test-locator
A locator component for finding components by their defined selector in tests.
Installation
npm install @instructure/ui-test-locator
Usage
import { testable } from '@instructure/ui-testable'
@testable()
export class MyComponent extends React.Component {
...
}
import { locator } from '@instructure/ui-test-locator'
import { MyComponent } from './MyComponent'
export const MyComponentLocator = locator(MyComponent.selector)
import { MyComponent } from './MyComponent'
import { MyComponentLocator } from './MyComponentLocator.js'
it('should render', () => {
await mount(<MyComponent />)
const myComponent = await MyComponentLocator.find()
expect(myComponent).to.exist()
})