Skip to content
Open
Show file tree
Hide file tree
Changes from 9 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
5 changes: 5 additions & 0 deletions jest.ssr.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ module.exports = {
// The test environment that will be used for testing
testEnvironment: 'jsdom',

// Match jest.config.js so the in-repo `"source"` export condition wins over `require`.
testEnvironmentOptions: {
customExportConditions: ['source']
},

setupFilesAfterEnv: ['<rootDir>scripts/setupTests.js'],

// The glob patterns Jest uses to detect test files
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@
"@storybook/react": "^10.0.0",
"@storybook/test-runner": "^0.24.0",
"@swc/core": "^1.3.36",
"@swc/jest": "^0.2.36",
"@swc/jest": "^0.2.39",
"@tailwindcss/postcss": "^4.0.17",
"@testing-library/dom": "^10.1.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^16.0.0",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.0",
"@testing-library/user-event": "patch:@testing-library/user-event@npm%3A14.6.1#~/.yarn/patches/@testing-library-user-event-npm-14.6.1-5da7e1d4e2.patch",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
Expand Down Expand Up @@ -160,15 +160,15 @@
"identity-obj-proxy": "^3.0.0",
"ignore-styles": "^5.0.1",
"is-mingw": "^2.0.0",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jest-junit": "^15.0.0",
"jest-matchmedia-mock": "^1.1.0",
"jest": "^30.0.0",
"jest-environment-jsdom": "^30.0.0",
"jest-junit": "^17.0.0",
"json5": "^2.2.3",
"lerna": "^3.13.2",
"lucide-react": "^0.517.0",
"md5": "^2.2.1",
"mdast-util-to-string": "^4.0.0",
"mock-match-media": "^1.0.0",
"motion": "^12.23.6",
"npm-cli-login": "^1.0.0",
"oxfmt": "^0.48.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,10 @@ describe('ActionGroup', function () {
let [button1, button2] = getAllByRole('radio');
await user.click(button1);
expect(button1).toHaveAttribute('disabled');
expect(onSelectionChange).toBeCalledTimes(0);
expect(onSelectionChange).toHaveBeenCalledTimes(0);
await user.click(button2);
expect(button2).not.toHaveAttribute('disabled');
expect(onSelectionChange).toBeCalledTimes(1);
expect(onSelectionChange).toHaveBeenCalledTimes(1);
});

it('ActionGroup handles selectedKeys (controlled)', async function () {
Expand All @@ -453,7 +453,7 @@ describe('ActionGroup', function () {
expect(button1).toHaveAttribute('aria-checked', 'true');
expect(button2).toHaveAttribute('aria-checked', 'false');
await user.click(button2);
expect(onSelectionChange).toBeCalledTimes(1);
expect(onSelectionChange).toHaveBeenCalledTimes(1);
expect(button1).toHaveAttribute('aria-checked', 'true');
expect(button2).toHaveAttribute('aria-checked', 'false');
});
Expand All @@ -470,7 +470,7 @@ describe('ActionGroup', function () {
expect(button1).toHaveAttribute('aria-checked', 'true');
expect(button2).toHaveAttribute('aria-checked', 'false');
await user.click(button2);
expect(onSelectionChange).toBeCalledTimes(1);
expect(onSelectionChange).toHaveBeenCalledTimes(1);
expect(button1).toHaveAttribute('aria-checked', 'false');
expect(button2).toHaveAttribute('aria-checked', 'true');
});
Expand All @@ -481,10 +481,10 @@ describe('ActionGroup', function () {

let [button1] = getAllByRole('radio');
await user.click(button1);
expect(onSelectionChange).toBeCalledTimes(1);
expect(onSelectionChange).toHaveBeenCalledTimes(1);
expect(new Set(onSelectionChange.mock.calls[0][0])).toEqual(new Set(['1']));
await user.click(button1);
expect(onSelectionChange).toBeCalledTimes(2);
expect(onSelectionChange).toHaveBeenCalledTimes(2);
expect(new Set(onSelectionChange.mock.calls[1][0])).toEqual(new Set([]));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ describe('SearchAutocomplete', function () {
});

let listbox = getByRole('listbox');
expect(onOpenChange).toBeCalledTimes(1);
expect(onOpenChange).toHaveBeenCalledTimes(1);
expect(onOpenChange).toHaveBeenCalledWith(true, 'focus');
await testSearchAutocompleteOpen(searchAutocomplete, listbox);
});
Expand Down
40 changes: 20 additions & 20 deletions packages/@adobe/react-spectrum/test/combobox/ComboBox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ describe('ComboBox', function () {
await comboboxTester.open({triggerBehavior: 'focus'});

let listbox = comboboxTester.listbox;
expect(onOpenChange).toBeCalledTimes(1);
expect(onOpenChange).toHaveBeenCalledTimes(1);
expect(onOpenChange).toHaveBeenCalledWith(true, 'focus');
await testComboBoxOpen(combobox, button, listbox);
});
Expand All @@ -486,7 +486,7 @@ describe('ComboBox', function () {
await comboboxTester.open({triggerBehavior: 'manual'});

let listbox = comboboxTester.listbox;
expect(onOpenChange).toBeCalledTimes(1);
expect(onOpenChange).toHaveBeenCalledTimes(1);
expect(onOpenChange).toHaveBeenCalledWith(true, 'focus');
await testComboBoxOpen(combobox, button, listbox);
});
Expand Down Expand Up @@ -1271,7 +1271,7 @@ describe('ComboBox', function () {
await user.keyboard('a');

expect(combobox.value).toBe('blah');
expect(onInputChange).toBeCalledTimes(1);
expect(onInputChange).toHaveBeenCalledTimes(1);
expect(onInputChange).toHaveBeenCalledWith('blaha');
});

Expand Down Expand Up @@ -1828,7 +1828,7 @@ describe('ComboBox', function () {
expect(onSelectionChange).toHaveBeenCalledTimes(1);
expect(onSelectionChange).toHaveBeenCalledWith('1');
expect(document.activeElement).toBe(combobox);
expect(onBlur).not.toBeCalled();
expect(onBlur).not.toHaveBeenCalled();
});

it('tab and shift tab move focus away from the combobox and select the focused item', async function () {
Expand Down Expand Up @@ -2773,19 +2773,19 @@ describe('ComboBox', function () {

if (!Name.includes('value') && !Name.includes('all')) {
// Check that onInputChange is firing appropriately for the comboboxes w/o user defined onInputChange handlers
expect(onInputChange).toBeCalledTimes(3);
expect(onInputChange).toHaveBeenCalledTimes(3);
expect(onInputChange).toHaveBeenLastCalledWith('One');
}

if (Name === 'controlled value and open') {
// Checking special case, spy is chained with the onSelectionChangeHandler
expect(onSelectionChange).toBeCalledTimes(2);
expect(onSelectionChange).toHaveBeenCalledTimes(2);
expect(onSelectionChange).toHaveBeenLastCalledWith('1');
}

if (!Name.includes('open') && !Name.includes('all')) {
// Check that onOpenChange is firing appropriately for the comboboxes w/o user defined onOpenChange handlers
expect(onOpenChange).toBeCalledTimes(4);
expect(onOpenChange).toHaveBeenCalledTimes(4);
expect(onOpenChange).toHaveBeenLastCalledWith(false, undefined);
}

Expand Down Expand Up @@ -2826,19 +2826,19 @@ describe('ComboBox', function () {

if (!Name.includes('value') && !Name.includes('all')) {
// Check that onInputChange is firing appropriately for the comboboxes w/o user defined onInputChange handlers
expect(onInputChange).toBeCalledTimes(3);
expect(onInputChange).toHaveBeenCalledTimes(3);
expect(onInputChange).toHaveBeenLastCalledWith('One');
}

if (Name === 'controlled value and open') {
// Checking special case, spy is chained with the onSelectionChangeHandler
expect(onSelectionChange).toBeCalledTimes(1);
expect(onSelectionChange).toHaveBeenCalledTimes(1);
expect(onSelectionChange).toHaveBeenLastCalledWith('1');
}

if (!Name.includes('open') && !Name.includes('all')) {
// Check that onOpenChange is firing appropriately for the comboboxes w/o user defined onOpenChange handlers
expect(onOpenChange).toBeCalledTimes(2);
expect(onOpenChange).toHaveBeenCalledTimes(2);
expect(onOpenChange).toHaveBeenLastCalledWith(false, undefined);
}

Expand Down Expand Up @@ -2894,19 +2894,19 @@ describe('ComboBox', function () {

if (!Name.includes('value') && !Name.includes('all')) {
// Check that onInputChange is firing appropriately for the comboboxes w/o user defined onInputChange handlers
expect(onInputChange).toBeCalledTimes(5);
expect(onInputChange).toHaveBeenCalledTimes(5);
expect(onInputChange).toHaveBeenLastCalledWith('One');
}

if (Name === 'controlled value and open') {
// Checking special case, spy is chained with the onSelectionChangeHandler
expect(onSelectionChange).toBeCalledTimes(2);
expect(onSelectionChange).toHaveBeenCalledTimes(2);
expect(onSelectionChange).toHaveBeenLastCalledWith('1');
}

if (!Name.includes('open') && !Name.includes('all')) {
// Check that onOpenChange is firing appropriately for the comboboxes w/o user defined onOpenChange handlers
expect(onOpenChange).toBeCalledTimes(4);
expect(onOpenChange).toHaveBeenCalledTimes(4);
expect(onOpenChange).toHaveBeenLastCalledWith(false, undefined);
}
});
Expand Down Expand Up @@ -2943,19 +2943,19 @@ describe('ComboBox', function () {

if (!Name.includes('value') && !Name.includes('all')) {
// Check that onInputChange is firing appropriately for the comboboxes w/o user defined onInputChange handlers
expect(onInputChange).toBeCalledTimes(5);
expect(onInputChange).toHaveBeenCalledTimes(5);
expect(onInputChange).toHaveBeenLastCalledWith('');
}

if (Name === 'controlled value and open') {
// Checking special case, spy is chained with the onSelectionChangeHandler
expect(onSelectionChange).toBeCalledTimes(1);
expect(onSelectionChange).toHaveBeenCalledTimes(1);
expect(onSelectionChange).toHaveBeenLastCalledWith(null);
}

if (!Name.includes('open') && !Name.includes('all')) {
// Check that onOpenChange is firing appropriately for the comboboxes w/o user defined onOpenChange handlers
expect(onOpenChange).toBeCalledTimes(2);
expect(onOpenChange).toHaveBeenCalledTimes(2);
expect(onOpenChange).toHaveBeenLastCalledWith(false, undefined);
}
});
Expand Down Expand Up @@ -2990,7 +2990,7 @@ describe('ComboBox', function () {
(!Name.includes('key') && !Name.includes('all')) ||
Name === 'controlled value and open'
) {
expect(onSelectionChange).toBeCalledTimes(1);
expect(onSelectionChange).toHaveBeenCalledTimes(1);
expect(onSelectionChange).toHaveBeenLastCalledWith('1');
}
expect(queryByRole('listbox')).toBeNull();
Expand All @@ -3006,7 +3006,7 @@ describe('ComboBox', function () {
if (Name === 'controlled value and open') {
// Checking special case, spy is chained with the onSelectionChangeHandler
// onSelectionChange is called on blur due to commitSelection (so that input value resets)
expect(onSelectionChange).toBeCalledTimes(2);
expect(onSelectionChange).toHaveBeenCalledTimes(2);
expect(onSelectionChange).toHaveBeenLastCalledWith('1');
}

Expand All @@ -3027,7 +3027,7 @@ describe('ComboBox', function () {
expect(queryByRole('listbox')).toBeNull();

if (!Name.includes('value') && !Name.includes('all')) {
expect(onInputChange).toBeCalledTimes(5);
expect(onInputChange).toHaveBeenCalledTimes(5);
expect(onInputChange).toHaveBeenLastCalledWith('New Text');
}
});
Expand Down Expand Up @@ -3060,7 +3060,7 @@ describe('ComboBox', function () {
(!Name.includes('key') && !Name.includes('all')) ||
Name === 'controlled value and open'
) {
expect(onSelectionChange).toBeCalledTimes(1);
expect(onSelectionChange).toHaveBeenCalledTimes(1);
expect(onSelectionChange).toHaveBeenLastCalledWith('1');
}
expect(queryByRole('listbox')).toBeNull();
Expand Down
2 changes: 1 addition & 1 deletion packages/@adobe/react-spectrum/test/image/Image.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Image', () => {
);
fireEvent.error(screen.getByAltText('Sky and roof'));

expect(mockOnErrorCallback).toBeCalled();
expect(mockOnErrorCallback).toHaveBeenCalled();
});

describe('crossorigin attribute', () => {
Expand Down
Loading