Skip to content

Commit 65d7ab0

Browse files
committed
feat(build): migrate to vitest
1 parent dfead2d commit 65d7ab0

File tree

198 files changed

+6898
-24864
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+6898
-24864
lines changed

.eslintrc.js

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
const path = require('path');
21
const prettierConf = require('./prettier.config.js');
32

43
module.exports = {
5-
parser: '@babel/eslint-parser',
64
parserOptions: {
7-
babelOptions: {
8-
configFile: path.resolve(__dirname, '.babelrc.json'),
9-
},
5+
ecmaVersion: 2022,
6+
sourceType: 'module',
107
},
118
extends: ['airbnb/base', 'prettier'],
129
rules: {
@@ -36,27 +33,22 @@ module.exports = {
3633
plugins: ['prettier'],
3734
globals: {
3835
__BASE_PATH__: false,
36+
__VTK_TEST_NO_WEBGL__: false,
37+
__VTK_TEST_WEBGPU__: false,
3938
VRFrameData: true,
4039
},
4140
settings: {
4241
'import/resolver': {
43-
webpack: {
44-
config: {
45-
resolve: {
46-
alias: {
47-
// Since vtk.js examples are written as if the vtk.js package is a dependency,
48-
// we need to resolve example imports as if they were referencing vtk.js/Sources.
49-
// the Examples/Utilities hack allows for imports from those folders, since our
50-
// last alias overrides vtk.js/* paths to point to vtk.js/Sources/*.
51-
'vtk.js/Data': path.resolve(__dirname, 'Data'),
52-
'vtk.js/Examples': path.resolve(__dirname, 'Examples'),
53-
'vtk.js/Utilities': path.resolve(__dirname, 'Utilities'),
54-
'vtk.js/Sources': path.resolve(__dirname, 'Sources'),
55-
'vtk.js': path.resolve(__dirname, 'Sources'),
56-
'@kitware/vtk.js': path.resolve(__dirname, 'Sources'),
57-
},
58-
},
59-
},
42+
alias: {
43+
map: [
44+
['vtk.js/Data', './Data'],
45+
['vtk.js/Examples', './Examples'],
46+
['vtk.js/Utilities', './Utilities'],
47+
['vtk.js/Sources', './Sources'],
48+
['vtk.js', './Sources'],
49+
['@kitware/vtk.js', './Sources'],
50+
],
51+
extensions: ['.js', '.json'],
6052
},
6153
},
6254
},
@@ -71,8 +63,8 @@ module.exports = {
7163
// ignore js files in utilities
7264
'Utilities/**/*.js',
7365
// ignore configs
74-
'karma.conf.js',
75-
'webpack.*.js',
66+
'vite.config.js',
67+
'vitest.config.js',
7668
'.eslintrc.js',
7769
],
7870
};

.github/workflows/build-test.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,34 @@ jobs:
1212
node: [22]
1313
name: ${{ matrix.os }} and node ${{ matrix.node }}
1414
steps:
15-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
1616
- name: Setup node
17-
uses: actions/setup-node@v1
17+
uses: actions/setup-node@v4
1818
with:
1919
node-version: ${{ matrix.node }}
2020
- name: Install dependencies
21-
run: |
22-
npm ci
23-
sudo apt-get install xvfb
21+
run: npm ci
22+
- name: Install Playwright browsers
23+
run: npx playwright install --with-deps chromium firefox
2424
- name: Build
2525
run: npm run build:release
2626
- name: Archive build output
2727
if: github.event_name != 'merge_group'
2828
uses: actions/upload-artifact@v4
2929
with:
30-
name: build-results-${{ matrix.runs_on }}-node_${{ matrix.node }}
30+
name: build-results-${{ matrix.os }}-node_${{ matrix.node }}
3131
path: dist
3232
retention-days: 15
3333
- name: Validate generated typescript definitions
3434
run: |
3535
npx tsc -p tsconfig.esm-check.json
36-
npx tsc -p tsconfig.umd-check.json
3736
- name: Chrome and Firefox tests
38-
run: xvfb-run --auto-servernum npm run test -- --browsers ChromeSwiftShader,Firefox
37+
run: xvfb-run --auto-servernum npm run test:reporter
3938
- name: Archive test results
4039
if: github.event_name != 'merge_group' && (success() || failure())
4140
uses: actions/upload-artifact@v4
4241
continue-on-error: true
4342
with:
44-
name: test-results-${{ matrix.runs_on }}-node_${{ matrix.node }}
45-
path: Utilities/TestResults/Test-Report.html
43+
name: test-results-${{ matrix.os }}-node_${{ matrix.node }}
44+
path: Utilities/TestResults/
4645
retention-days: 15

.github/workflows/pr-checks.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ jobs:
88
runs-on: ubuntu-24.04
99
name: Check and lint PR
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v4
1212
with:
1313
fetch-depth: 0 # needed so commitlint can lint the commits
1414
- name: Setup node
15-
uses: actions/setup-node@v1
15+
uses: actions/setup-node@v4
1616
with:
17-
node-version: 20
17+
node-version: 22
1818
- run: npm ci
1919
- name: Enforce code style
2020
run: npm run validate

.github/workflows/publish.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,32 @@ jobs:
2222
name: npm
2323
steps:
2424
- name: Checkout
25-
uses: actions/checkout@v2
25+
uses: actions/checkout@v4
2626
with:
2727
fetch-depth: 0
2828
- name: Setup node
2929
uses: actions/setup-node@v4
3030
with:
3131
node-version: 22
3232
- name: Install dependencies
33-
run: |
34-
npm ci
35-
sudo apt-get install xvfb
33+
run: npm ci
34+
- name: Install Playwright browsers
35+
run: npx playwright install --with-deps chromium firefox
3636
- name: Build
3737
run: npm run build:release
3838
- name: Validate code style
3939
run: npm run validate
4040
- name: Validate generated typescript definitions
4141
run: |
4242
npx tsc -p tsconfig.esm-check.json
43-
npx tsc -p tsconfig.umd-check.json
4443
- name: Chrome and Firefox tests
45-
run: xvfb-run --auto-servernum npm run test -- --browsers ChromeSwiftShader,Firefox
44+
run: xvfb-run --auto-servernum npm run test:reporter
4645
- name: Archive test results
4746
if: always()
4847
uses: actions/upload-artifact@v4
4948
with:
5049
name: test-results
51-
path: Utilities/TestResults/Test-Report.html
50+
path: Utilities/TestResults/
5251
retention-days: 15
5352
- name: Release
5453
env:
@@ -70,11 +69,11 @@ jobs:
7069
runs-on: ubuntu-latest
7170
steps:
7271
- name: Checkout
73-
uses: actions/checkout@v2
72+
uses: actions/checkout@v4
7473
with:
7574
fetch-depth: 1
7675
- name: Setup node
77-
uses: actions/setup-node@v1
76+
uses: actions/setup-node@v4
7877
with:
7978
node-version: 22
8079
- name: Install dependencies
Lines changed: 14 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,37 @@
1-
import test from 'tape';
2-
1+
import { it, expect } from 'vitest';
32
import vtkCellArray from 'vtk.js/Sources/Common/Core/CellArray';
43
import { VtkDataTypes } from 'vtk.js/Sources/Common/Core/DataArray/Constants';
54

6-
test('Test cell array constructor', (t) => {
5+
it('Test cell array constructor', () => {
76
// Empty cell arrays are allowed (empty=true in DEFAULT_VALUES)
87
const emptyCellArray = vtkCellArray.newInstance();
9-
t.equal(
10-
emptyCellArray.getDataType(),
11-
VtkDataTypes.UNSIGNED_INT,
12-
'empty init data type'
13-
);
14-
t.equal(emptyCellArray.getNumberOfCells(), 0, 'empty init number of cells');
8+
expect(emptyCellArray.getDataType()).toBe(VtkDataTypes.UNSIGNED_INT);
9+
expect(emptyCellArray.getNumberOfCells()).toBe(0);
1510

1611
const uintCellArray = vtkCellArray.newInstance({ values: [3, 0, 1, 2] });
17-
t.equal(
18-
uintCellArray.getDataType(),
19-
VtkDataTypes.UNSIGNED_INT,
20-
'uint init data type'
21-
);
22-
t.equal(uintCellArray.getNumberOfCells(), 1, 'uint init number of cells');
12+
expect(uintCellArray.getDataType()).toBe(VtkDataTypes.UNSIGNED_INT);
13+
expect(uintCellArray.getNumberOfCells()).toBe(1);
2314

2415
const charCellArray = vtkCellArray.newInstance({
2516
dataType: VtkDataTypes.CHAR,
2617
values: [3, 0, 1, 2],
2718
});
28-
t.equal(
29-
charCellArray.getDataType(),
30-
VtkDataTypes.CHAR,
31-
'char init data type'
32-
);
33-
t.equal(charCellArray.getNumberOfCells(), 1, 'char init number of cells');
34-
35-
t.end();
19+
expect(charCellArray.getDataType()).toBe(VtkDataTypes.CHAR);
20+
expect(charCellArray.getNumberOfCells()).toBe(1);
3621
});
3722

38-
test('Test vtkCellArray insertNextCell', (t) => {
23+
it('Test vtkCellArray insertNextCell', () => {
3924
const cellArray = vtkCellArray.newInstance({
4025
dataType: 'Uint16Array',
4126
empty: true,
4227
numberOfComponents: 1,
4328
});
4429
cellArray.insertNextCell([0, 1, 2]);
45-
t.equal(
46-
cellArray.getNumberOfCells(),
47-
1,
48-
'number of cells after first insertNextCell'
49-
);
50-
t.deepEqual(
51-
cellArray.getData(),
52-
Uint16Array.from([3, 0, 1, 2]),
53-
'getData after first insertNextCell'
54-
);
30+
expect(cellArray.getNumberOfCells()).toBe(1);
31+
expect(cellArray.getData()).toEqual(Uint16Array.from([3, 0, 1, 2]));
5532
cellArray.insertNextCell([3, 4, 5, 6]);
56-
t.equal(
57-
cellArray.getNumberOfCells(),
58-
2,
59-
'number of cells after second insertNextCell'
60-
);
61-
t.deepEqual(
62-
cellArray.getData(),
63-
Uint16Array.from([3, 0, 1, 2, 4, 3, 4, 5, 6]),
64-
'getData after second insertNextCell'
33+
expect(cellArray.getNumberOfCells()).toBe(2);
34+
expect(cellArray.getData()).toEqual(
35+
Uint16Array.from([3, 0, 1, 2, 4, 3, 4, 5, 6])
6536
);
66-
t.end();
6737
});

0 commit comments

Comments
 (0)