Skip to content
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
9 changes: 9 additions & 0 deletions .changeset/fields-jest-dom-self-declared.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
---

Test-only change in `@object-ui/fields`: the fifteen test files that use
`@testing-library/jest-dom` matchers now import jest-dom themselves instead of
relying on a sibling test file's bare import to register the matcher types
program-wide (objectui#8722). No published behaviour changes — `files` ships
`dist` only, and no artifact derived from a `.test.` file reaches it (measured,
with a control: 0 test-derived files in `dist`, 80 `.d.ts` present).
1 change: 1 addition & 0 deletions packages/fields/src/__tests__/field-carrier-sdui.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import React, { Suspense } from 'react';
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
import { render, screen, cleanup } from '@testing-library/react';
import '@testing-library/jest-dom';
import { ComponentRegistry } from '@object-ui/core';
import { SchemaRenderer } from '@object-ui/react';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import { describe, it, expect } from 'vitest';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';

import { TextField } from '../widgets/TextField';
import { BooleanField } from '../widgets/BooleanField';
Expand Down
1 change: 1 addition & 0 deletions packages/fields/src/complex-widgets.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { render, screen, fireEvent, waitFor, act } from '@testing-library/react';
import '@testing-library/jest-dom';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { LookupField } from './widgets/LookupField';
import { ActionProvider } from '@object-ui/react';
Expand Down
1 change: 1 addition & 0 deletions packages/fields/src/datetime-widgets.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import '@testing-library/jest-dom';
import { describe, it, expect, vi } from 'vitest';
import { DateField } from './widgets/DateField';
import { DateTimeField } from './widgets/DateTimeField';
Expand Down
1 change: 1 addition & 0 deletions packages/fields/src/widgets/ImageLightbox.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { render, screen, fireEvent } from '@testing-library/react';
import '@testing-library/jest-dom';
import { describe, it, expect } from 'vitest';
import { I18nProvider } from '@object-ui/i18n';
import { ImageLightbox, type ImageLightboxProps } from './ImageLightbox';
Expand Down
1 change: 1 addition & 0 deletions packages/fields/src/widgets/LookupField.dependsOn.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/

import { render, screen, fireEvent, waitFor, act } from '@testing-library/react';
import '@testing-library/jest-dom';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { LookupField } from './LookupField';
import { RecordPickerDialog } from './RecordPickerDialog';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

import { render, screen, fireEvent, waitFor, act } from '@testing-library/react';
import '@testing-library/jest-dom';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import type { LookupFieldMetadata } from '@object-ui/types';
import { LookupField } from './LookupField';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*/

import { render, screen, fireEvent, waitFor, act, cleanup } from '@testing-library/react';
import '@testing-library/jest-dom';
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { LookupField } from './LookupField';
import { SelectField } from './SelectField';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*/

import { render, screen, cleanup } from '@testing-library/react';
import '@testing-library/jest-dom';
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { LookupField } from './LookupField';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import * as React from 'react';
import { describe, it, expect, vi, afterEach } from 'vitest';
import { render, screen, fireEvent, cleanup, waitFor, act } from '@testing-library/react';
import '@testing-library/jest-dom';
import type { LookupFieldMetadata } from '@object-ui/types';
import { LookupField } from './LookupField';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import * as React from 'react';
import { describe, it, expect, vi, afterEach } from 'vitest';
import { render, screen, cleanup, waitFor, act, fireEvent } from '@testing-library/react';
import '@testing-library/jest-dom';
import { SchemaRendererContext } from '@object-ui/react';
import { LookupField } from './LookupField';
import { RecordPickerDialog } from './RecordPickerDialog';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
*/

import { render, screen, fireEvent, waitFor, act } from '@testing-library/react';
import '@testing-library/jest-dom';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { LookupField } from './LookupField';
import { PeoplePicker } from './PeoplePicker';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

import React from 'react';
import { render, screen, fireEvent, waitFor, act } from '@testing-library/react';
import '@testing-library/jest-dom';
import { describe, it, expect, vi, beforeAll } from 'vitest';
import { I18nProvider } from '@object-ui/i18n';
import { RecordPickerDialog } from './RecordPickerDialog';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/

import { render, screen, waitFor } from '@testing-library/react';
import '@testing-library/jest-dom';
import { describe, it, expect, vi } from 'vitest';
import { RecordPickerDialog } from './RecordPickerDialog';
import { getCellRenderer } from '../index';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import { describe, it, expect, vi } from 'vitest';
import React from 'react';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import { SelectField } from './SelectField';
import { MultiSelectField } from './MultiSelectField';
import { CheckboxesField } from './CheckboxesField';
Expand Down
28 changes: 24 additions & 4 deletions packages/fields/tsconfig.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,30 @@
// program does not name it either — so leaving it unset is what reproduces
// the exact program these tests were checked by until now, which is the
// property objectui#4006 had to preserve while moving the coverage.
// Measured: no test file here uses `global`, and the seven suites that use
// `@testing-library/jest-dom` matchers `import '@testing-library/jest-dom'`
// explicitly, so its global augmentation reaches the whole program through
// that import (plugin-list's lesson).
// Re-measured here on this program's own resolved file list (objectui#8722
// round 2) — `tsc -p tsconfig.test.json --listFiles`, never a glob, because
// these tests sit at four different depths and any single glob reads a
// partial population. Of its 161 test files:
//
// - None uses the Node `global` object, and one could not slip in
// unnoticed: injecting `global.setTimeout` into a test file here is
// TS2304, against an unmutated exit 0. That is what keeps `types` unset
// safe on the Node axis, and it is the claim this paragraph rests on.
// - Every one of the 92 files that call `@testing-library/jest-dom`
// matchers now carries its own `import '@testing-library/jest-dom';`,
// so no file's matchers are typed only by a DIFFERENT file's import.
// 119 files carry that import in all; the 27 beyond the 92 do not use
// a matcher themselves.
//
// Those counts are a reading taken once, not a live fact. The instrument
// that re-derives them is `pnpm census:tsconfig-test-parity`, and the
// column that must stay 0 for this package is `leaning`.
//
// What the second point does NOT claim is that any single import is
// load-bearing. The augmentation is still PROGRAM-scoped, so removing any
// proper subset of those 119 imports leaves the program green (measured).
// What changed is that every matcher user is now also a supplier, so no
// file here can be reddened by an edit to a file it does not control.
//
// `paths` drops the root tsconfig's source-tree mappings so `@object-ui/*`
// and `@objectstack/spec/*` resolve through each workspace dependency's
Expand Down
Loading