Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test] Remove userAgent override in jsdom env #42344

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/mui-material/src/Tabs/Tabs.test.js
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we are doing this exactly ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We skip some tests in JSDOM because of the missing APIs, hence we need to know when the test is running in JSDOM

Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function hasRightScrollButton(container) {

describe('<Tabs />', () => {
// tests mocking getBoundingClientRect prevent mocha to exit
const isJSDOM = navigator.userAgent === 'node.js';
const isJSDOM = /jsdom/.test(window.navigator.userAgent);

const { clock, render, renderToString } = createRenderer();

Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/src/internal/animate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('animate', () => {

before(function beforeHook() {
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
const isJSDOM = navigator.userAgent === 'node.js';
const isJSDOM = /jsdom/.test(window.navigator.userAgent);
if (isJSDOM || isSafari) {
// The test fails on Safari with just:
//
Expand Down
4 changes: 0 additions & 4 deletions packages/test-utils/src/createDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ function createDOM() {
}
global.window.Touch = Touch;

global.navigator = {
userAgent: 'node.js',
};

Object.keys(dom.window)
.filter((key) => !blacklist.includes(key))
.concat(whitelist)
Expand Down
Loading