Skip to content

Replace Jest with Vitest 2 (#4728) #6453

Replace Jest with Vitest 2 (#4728)

Replace Jest with Vitest 2 (#4728) #6453

Workflow file for this run

name: Tests
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
permissions:
checks: write
pull-requests: write
contents: write
jobs:
code-hygiene:
name: Code Hygiene
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- run: npm ci
- run: npm run lint
if: '!cancelled()'
- run: npm run lint-css
if: '!cancelled()'
- run: npm run generate-typings
if: '!cancelled()'
- run: npm run typecheck
if: '!cancelled()'
- run: npm run generate-docs
- name: Build docs using docker and mkdocs-material
run: |
rm docs/README.md
rm -rf docs/API/_media
docker run --rm -v ${PWD}:/docs squidfunk/mkdocs-material build --strict
- name: Check spelling
# This need to run after the docs are built
run: npm run spellcheck
unit-tests:
name: Unit tests and Coverage
runs-on: ubuntu-latest
timeout-minutes: 40
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Start display server
run: nohup Xvfb &
echo "DISPLAY=:0" >> $GITHUB_ENV
- run: npm ci
- run: npm run test-unit-ci
- name: Upload test results to Codecov
if: '!cancelled()'
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
files: ${{ github.workspace }}/coverage/vitest/unit/coverage-final.json
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
disable_search: true
integration-tests:
name: Integration tests
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 40
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- run: npm ci
- run: npm run build-dist
- uses: actions/upload-artifact@v4
if: '!cancelled()'
with:
name: build-dist-${{ matrix.os }}
path: dist/maplibre-gl.js
- run: npm run test-integration-ci
- name: Upload coverage reports to Codecov
if: '!cancelled()'
uses: codecov/codecov-action@v5
with:
files: ${{ github.workspace }}/coverage/vitest/integration/coverage-final.json
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
disable_search: true
render-tests:
name: Render tests
env:
SPLIT_COUNT: 3
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
split: [0, 1, 2]
runs-on: ${{ matrix.os }}
timeout-minutes: 120
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: install CJK fonts for local ideographs render tests
if: runner.os == 'Linux'
run: sudo apt install fonts-noto-cjk
- run: npm ci
- name: Start display server
if: runner.os == 'Linux'
run: nohup Xvfb &
echo "DISPLAY=:0" >> $GITHUB_ENV
- run: npm run build-dist
- name: Run Render tests
run: npm run test-render
env:
CURRENT_SPLIT_INDEX: ${{ matrix.split }}
- name: Upload coverage reports to Codecov
if: '!cancelled()'
uses: codecov/codecov-action@v5
with:
files: ${{ github.workspace }}/coverage/render/codecov.json
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
disable_search: true
- name: Upload test results to Codecov
if: '!cancelled()'
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload render test failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: render-test-report-${{ matrix.os }}-${{ matrix.split }}
path: ${{ github.workspace }}/test/integration/render/results.html
build-tests:
name: Build tests
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- run: npm ci
- run: npm run build-dist
- run: npm run test-build-ci