From 0f62b01d64a28cb74270ef31412d3e8f7c3b8dc9 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Wed, 15 Feb 2023 19:24:35 -0500 Subject: [PATCH] Move Jest tests to filtered GitHub Action (#23623) --- .circleci/config.yml | 8 ------- .github/workflows/test-js.yml | 41 +++++++++++++++++++++++++++++++++++ jest.config.js | 29 ++++++++++--------------- 3 files changed, 52 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/test-js.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index 0b31238937..183ad9048e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -217,11 +217,3 @@ workflows: - test-two-step-migrations: requires: - build - - node/run: - cache-version: v1 - name: test-webui - pkg-manager: yarn - requires: - - build - version: '16.19' - yarn-run: test:jest diff --git a/.github/workflows/test-js.yml b/.github/workflows/test-js.yml new file mode 100644 index 0000000000..60b8e318ef --- /dev/null +++ b/.github/workflows/test-js.yml @@ -0,0 +1,41 @@ +name: JavaScript Testing +on: + push: + branches-ignore: + - 'dependabot/**' + paths: + - 'package.json' + - 'yarn.lock' + - '.nvmrc' + - '**/*.js' + - '**/*.snap' + - '.github/workflows/test-js.yml' + + pull_request: + paths: + - 'package.json' + - 'yarn.lock' + - '.nvmrc' + - '**/*.js' + - '**/*.snap' + - '.github/workflows/test-js.yml' + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Clone repository + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + cache: yarn + node-version-file: '.nvmrc' + + - name: Install all yarn packages + run: yarn --frozen-lockfile + + - name: Jest testing + run: yarn test:jest --reporters github-actions summary diff --git a/jest.config.js b/jest.config.js index d7b5610b81..69222ea357 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,9 +1,7 @@ -module.exports = { - 'testEnvironment': 'jsdom', - 'projects': [ - '/app/javascript/mastodon', - ], - 'testPathIgnorePatterns': [ +/** @type {import('jest').Config} */ +const config = { + testEnvironment: 'jsdom', + testPathIgnorePatterns: [ '/node_modules/', '/vendor/', '/config/', @@ -11,22 +9,17 @@ module.exports = { '/public/', '/tmp/', ], - 'setupFiles': [ - 'raf/polyfill', - ], - 'setupFilesAfterEnv': [ - '/app/javascript/mastodon/test_setup.js', - ], - 'collectCoverageFrom': [ + setupFiles: ['raf/polyfill'], + setupFilesAfterEnv: ['/app/javascript/mastodon/test_setup.js'], + collectCoverageFrom: [ 'app/javascript/mastodon/**/*.js', '!app/javascript/mastodon/features/emoji/emoji_compressed.js', '!app/javascript/mastodon/locales/locale-data/*.js', '!app/javascript/mastodon/service_worker/entry.js', '!app/javascript/mastodon/test_setup.js', ], - 'coverageDirectory': '/coverage', - 'moduleDirectories': [ - '/node_modules', - '/app/javascript', - ], + coverageDirectory: '/coverage', + moduleDirectories: ['/node_modules', '/app/javascript'], }; + +module.exports = config;