fix: add getConfig to types#668
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit da4a3f1:
|
Codecov Report
@@ Coverage Diff @@
## master #668 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 24 24
Lines 593 593
Branches 148 148
=========================================
Hits 593 593 Continue to review full report at Codecov.
|
eps1lon
left a comment
There was a problem hiding this comment.
We currently don't document this function: https://testing-library.com/docs/dom-testing-library/api-configuration#docsNav nor mention it anywhere.
I guess you use this to configure some test suites differently and restore the previous config?
Not necessarily related to this PR but I'd very much prefer adding types for documentation instead of adding types for code.
|
I was looking into extending the config for Angular Testing Library, to add default imports. This way, Angular Testing Library retrieves the config with For example: beforeEach(() => {
configure({
defaultImports: [ReactiveFormsModule],
});
});
test('test 1', async () => {
await render(MyComponent)
})
test('test 2', async () => {
await render(MyComponent)
})
// VS
test('test 1', async () => {
await render(MyComponent, { imports: [ReactiveFormsModule] })
})
test('test 2', async () => {
await render(MyComponent, { imports: [ReactiveFormsModule] })
})An alternative could be that Angular Testing Library provides its own |
|
Interesting. I'm not sure you need this method to do that. You could simply make your own configure wrapper that takes custom config properties and forwards along the rest. I think it would be dangerous to set the DOM Testing Library config with properties it doesn't support. That said, we use getConfig in user-event so it's not just exposed by accident and should probably be typed for that reason. |
I'd be careful with adding additional properties to the config object from Have you considered implementing your own import { configure } from '@testing-library/angular';
configure({ property: 'foo', someFlag: false, dom: domTestingLibraryConfig })I guess this is currently problematic for any library extending the config of DTL. |
|
I have not, but I think I'm going to go with your proposition @eps1lon 👍. The current implementation looks like this, but I'm not too happy about it. function configure(config: Partial<Config>) {
dtlConfigure({
defaultImports: config.defaultImports,
} as Partial<dtlConfig>);
}
@kentcdodds feel free to close or merge this PR. |
|
🎉 This PR is included in version 7.17.2 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
What:
getConfigtype to the TS typingsWhy:
getConfigisn't exportedHow:
Checklist:
docs site