Skip to content

Commit 72c174d

Browse files
perf: only inject DOM Testing Library if necessary
If window.TestingLibraryDom exists there is no need to set it up again. If it does exist it should still be configured to make sure it is using the correct config.
1 parent 92cceaa commit 72c174d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ const DOM_TESTING_LIBRARY_UMD = fs
2727
let _config: Partial<Config>
2828

2929
async function injectDOMTestingLibrary(container: Element) {
30-
await container.execute(DOM_TESTING_LIBRARY_UMD)
30+
const shouldInject = await container.execute(function () {
31+
return !window.TestingLibraryDom
32+
})
33+
34+
if (shouldInject) {
35+
await container.execute(DOM_TESTING_LIBRARY_UMD)
36+
}
3137

3238
if (_config) {
3339
await container.execute(function (config: Config) {

0 commit comments

Comments
 (0)