diff --git a/.changeset/slow-otters-deny.md b/.changeset/slow-otters-deny.md new file mode 100644 index 00000000000..2d8cf3b7449 --- /dev/null +++ b/.changeset/slow-otters-deny.md @@ -0,0 +1,5 @@ +--- +'@itwin/itwinui-react': patch +--- + +Fixed an issue where the internal unit test detection logic was incorrectly treating Cypress like a unit test environment. diff --git a/packages/itwinui-react/src/utils/functions/dev.ts b/packages/itwinui-react/src/utils/functions/dev.ts index 32a5fc3a066..5fb8e911d2b 100644 --- a/packages/itwinui-react/src/utils/functions/dev.ts +++ b/packages/itwinui-react/src/utils/functions/dev.ts @@ -6,10 +6,12 @@ // @ts-expect-error -- jest is not used in iTwinUI but may be used in consuming apps const isJest = typeof jest !== 'undefined'; +const isCypress = typeof (globalThis as any).Cypress !== 'undefined'; const isMocha = typeof (globalThis as any).beforeEach !== 'undefined' && `${(globalThis as any).beforeEach}`.replace(/\s/g, '') === - 'function(name,fn){suites[0].beforeEach(name,fn);}'; + 'function(name,fn){suites[0].beforeEach(name,fn);}' && + !isCypress; const isVitest = typeof (globalThis as any).__vitest_index__ !== 'undefined'; const isUnitTest = isJest || isVitest || isMocha;