diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0276cc89..7e5083dd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,7 +5,7 @@ permissions: contents: read jobs: - test: + unit: runs-on: ubuntu-latest steps: @@ -34,3 +34,28 @@ jobs: - name: Run integration tests run: npm run test:integration + + integration: + runs-on: ubuntu-latest + strategy: + matrix: + browser: [chromium, firefox, webkit] + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Use Node.js + uses: actions/setup-node@v6 + with: + cache: npm + node-version-file: .nvmrc + + - name: Install dependencies + run: npm ci --prefer-offline + + - name: Install Playwright browsers + run: npx playwright install ${{ matrix.browser == 'webkit' && '--with-deps' || '' }} ${{ matrix.browser }} + + - name: Run browser tests on ${{ matrix.browser }} + run: npm test -- --config=vitest.config.browser.mts --browser=${{ matrix.browser }} diff --git a/__tests__/__snapshots__/index.test.tsx.snap b/__tests__/__snapshots__/index.test.tsx.snap index 8c56d99e..df4ceb03 100644 --- a/__tests__/__snapshots__/index.test.tsx.snap +++ b/__tests__/__snapshots__/index.test.tsx.snap @@ -340,22 +340,3 @@ exports[`replace option > replaces the element if a valid React element is retur `; - -exports[`trim option > preserves whitespace text nodes when disabled if valid in parent (default) 1`] = ` - - - - - - - - -
- hello - - - - -   -
-`; diff --git a/__tests__/attributes-to-props.test.ts b/__tests__/attributes-to-props/index.test.ts similarity index 94% rename from __tests__/attributes-to-props.test.ts rename to __tests__/attributes-to-props/index.test.ts index 46839025..47f4b30e 100644 --- a/__tests__/attributes-to-props.test.ts +++ b/__tests__/attributes-to-props/index.test.ts @@ -1,5 +1,6 @@ -import attributesToProps, { type Attributes } from '../src/attributes-to-props'; -import * as utilities from '../src/utilities'; +import attributesToProps, { + type Attributes, +} from '../../src/attributes-to-props'; it('returns empty object is argument is undefined', () => { expect(attributesToProps()).toEqual({}); @@ -353,24 +354,3 @@ describe('attributesToProps with custom attribute', () => { `); }); }); - -describe('utilities.PRESERVE_CUSTOM_ATTRIBUTES=false', () => { - const emptyProps = {}; - - beforeAll(() => { - vi.spyOn(utilities, 'PRESERVE_CUSTOM_ATTRIBUTES', 'get').mockReturnValue( - false, - ); - }); - - afterAll(() => { - vi.restoreAllMocks(); - }); - - it('omits unknown attributes', () => { - const attributes = { - unknownAttribute: 'someValue', - }; - expect(attributesToProps(attributes)).toEqual(emptyProps); - }); -}); diff --git a/__tests__/attributes-to-props/preserve-custom-attributes.test.ts b/__tests__/attributes-to-props/preserve-custom-attributes.test.ts new file mode 100644 index 00000000..4085429c --- /dev/null +++ b/__tests__/attributes-to-props/preserve-custom-attributes.test.ts @@ -0,0 +1,15 @@ +import attributesToProps from '../../src/attributes-to-props'; + +vi.mock('../../src/utilities', async (importOriginal) => ({ + ...(await importOriginal()), + PRESERVE_CUSTOM_ATTRIBUTES: false, +})); + +describe('utilities.PRESERVE_CUSTOM_ATTRIBUTES=false', () => { + const emptyProps = {}; + + it('omits unknown attributes', () => { + const attributes = { unknownAttribute: 'someValue' }; + expect(attributesToProps(attributes)).toEqual(emptyProps); + }); +}); diff --git a/__tests__/dom-to-react/__snapshots__/custom-attributes.test.ts.snap b/__tests__/dom-to-react/__snapshots__/custom-attributes.test.ts.snap new file mode 100644 index 00000000..a8bbb95c --- /dev/null +++ b/__tests__/dom-to-react/__snapshots__/custom-attributes.test.ts.snap @@ -0,0 +1,13 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`domToReact > when React version is 15 > removes unknown attributes 1`] = ` + +`; diff --git a/__tests__/dom-to-react/__snapshots__/index.test.tsx.snap b/__tests__/dom-to-react/__snapshots__/index.test.tsx.snap new file mode 100644 index 00000000..09f726b7 --- /dev/null +++ b/__tests__/dom-to-react/__snapshots__/index.test.tsx.snap @@ -0,0 +1,125 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`domToReact > converts