diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6f0b01bb763b..1c38fc89293d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -124,7 +124,7 @@ jobs: run: | node -v npm -v - yarn test --silent --shard=${{ matrix.shardIndex}}/${{ matrix.shardTotal }} + yarn test --silent --shard=${{ matrix.shardIndex}}/${{ matrix.shardTotal }} --testSequencer=../../../shardSequencer.cjs env: SANITY_CI_CLI_AUTH_TOKEN: ${{ secrets.SANITY_CI_CLI_AUTH_TOKEN }} GITHUB_SHARD_IDENTIFIER: ${{ matrix.shardIndex }}-${{ matrix.shardTotal }} diff --git a/package.json b/package.json index 649889b1894a..0daafb555256 100644 --- a/package.json +++ b/package.json @@ -91,6 +91,7 @@ "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.23.0", "@bjoerge/mutiny": "^0.0.2", + "@jest/test-sequencer": "^29.7.0", "@optimize-lodash/rollup-plugin": "^4.0.4", "@playwright/test": "^1.38.1", "@sanity/client": "^6.7.0", diff --git a/packages/@sanity/portable-text-editor/e2e-tests/jest.config.cjs b/packages/@sanity/portable-text-editor/e2e-tests/e2e.config.cjs similarity index 100% rename from packages/@sanity/portable-text-editor/e2e-tests/jest.config.cjs rename to packages/@sanity/portable-text-editor/e2e-tests/e2e.config.cjs diff --git a/packages/@sanity/portable-text-editor/package.json b/packages/@sanity/portable-text-editor/package.json index 2715e306b73f..15275672e27d 100644 --- a/packages/@sanity/portable-text-editor/package.json +++ b/packages/@sanity/portable-text-editor/package.json @@ -59,7 +59,7 @@ "prettier": "prettier --write './**/*.{ts,tsx,js,css,html}'", "dev": "cd ./test/ && ts-node serve", "test": "jest", - "test:e2e": "cd e2e-tests && jest", + "test:e2e": "cd e2e-tests && jest --config=e2e.config.cjs", "test:watch": "jest --watch", "watch": "pkg-utils watch --tsconfig tsconfig.lib.json" }, diff --git a/shardSequencer.cjs b/shardSequencer.cjs new file mode 100644 index 000000000000..c56152b98bbb --- /dev/null +++ b/shardSequencer.cjs @@ -0,0 +1,9 @@ +'use strict' + +const Sequencer = require('@jest/test-sequencer').default + +module.exports = class JestShardSequencer extends Sequencer { + shard(tests) { + return tests.filter((test) => !test.path.includes('e2e')) + } +} diff --git a/yarn.lock b/yarn.lock index 18464094fba0..932530882e82 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15999,6 +15999,11 @@ yargs@^17.3.0, yargs@^17.3.1: y18n "^5.0.5" yargs-parser "^21.1.1" +yarn@^1.22.19: + version "1.22.19" + resolved "https://registry.npmjs.org/yarn/-/yarn-1.22.19.tgz#4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447" + integrity sha512-/0V5q0WbslqnwP91tirOvldvYISzaqhClxzyUKXYxs07yUILIs5jx/k6CFe8bvKSkds5w+eiOqta39Wk3WxdcQ== + yauzl@^2.4.2: version "2.10.0" resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9"