@instructure/ui-test-locator
v10.10.0
Published
A locator component for finding components by their defined selector in tests.
Downloads
22,324
Maintainers
Keywords
Readme
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
---
type: code
---
// MyComponent.js
import { testable } from '@instructure/ui-testable'
@testable()
export class MyComponent extends React.Component {
...
}
// MyComponentLocator.js
import { locator } from '@instructure/ui-test-locator'
import { MyComponent } from './MyComponent'
export const MyComponentLocator = locator(MyComponent.selector)
// MyComponent.test.js
import { MyComponent } from './MyComponent'
import { MyComponentLocator } from './MyComponentLocator.js'
it('should render', () => {
await mount(<MyComponent />)
const myComponent = await MyComponentLocator.find()
expect(myComponent).to.exist()
})