Skip to content

Commit b51297e

Browse files
authored
Merge pull request #2161 from floryst/image-tests
Update test framework
2 parents 3acb754 + 13b9be1 commit b51297e

File tree

26 files changed

+25990
-475
lines changed

26 files changed

+25990
-475
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const path = require('path');
22
const prettierConf = require('./prettier.config.js');
33

44
module.exports = {
5+
parser: '@babel/eslint-parser',
56
extends: ['airbnb/base', 'prettier'],
67
rules: {
78
'prettier/prettier': ['error', prettierConf],

Documentation/content/docs/develop_test.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ test.onlyIfWebGL('Test vtkClassName Rendering', (t) => {
9090

9191
## Registering a test
9292

93-
As opposed to examples and api documentation, tests won't be picked up automatically and it is the responsibility of the author to register it on the test suite.
94-
_This may change as the project evolves._
95-
96-
To add a test to the suite, you need to import it inside `Sources/tests.js`.
93+
Tests are automatically picked up by Karma, our test runner.
9794

9895
## Running all the tests
9996

@@ -103,11 +100,20 @@ In order to run all the registered test, run the following command:
103100
$ npm run test
104101
```
105102

106-
That command can also be written as `npm t` or `npm test` however it will run all tests.
103+
That command can also be written as `npm t` or `npm test`.
104+
105+
## Test reporting
106+
107+
After running tests, a report file will be written to `Utilities/TestResults/Test-Report.html`. Opening this file in a browser will show which tests have passed, which tests have failed, and which tests have associated images.
107108

108109
## Running a single test for debugging
109110

110-
Since we have single entry points for all the tests we run, you can comment out every file except the one you want to run inside `Sources/tests.js`.
111+
In your test file, specifying `test.only(...)` will tell the test harness to only run your test. Don't forget to remove it once your test is ready!
112+
113+
```diff
114+
-test('my test description', (t) => {})
115+
+test.only('my test description', (t) => {})
116+
```
111117

112118
Then executing `npm t` will only run that file, but if you want to open a browser and debug the actual code, you can do it with the following command:
113119

@@ -126,9 +132,8 @@ Follow the following procedure to create a new baseline or change an existing ba
126132
- Add an invalid baseline (any PNG file) and rename it as the required baseline.
127133
For example, to create a baseline for `testCylinder.js` copy *testCone.png* to *Sources/Filters/Sources/CylinderSource/test/testCylinder.png*.
128134
- Run the test as per [Running a single test for debugging](#Running-a-single-test-for-debugging). The test should fail because of the invalid baseline.
129-
- The test execution creates a file **Documentation/content/coverage/tests.md**.
130-
Rename this file as **tests.html** and open it in the browser.
131-
- The file should show the test output versus the invalid baseline image.
135+
- The test execution creates a file **Utilities/TestResults/Test-Report.html**. Open this in the browser.
136+
- The file should show the test output versus the invalid baseline image, as well as a diff.
132137
Right-click on the test output image and save it as the valid baseline.
133138
- Re-run the test to ensure that it passes with the valid baseline.
134139
- Commit the baseline image to the git source tree.

Sources/Common/Core/LookupTable/test/testCategoricalColors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ test.onlyIfWebGL('Test Categorical Colors', (t) => {
114114
[baseline],
115115
'Common/Core/LookupTable/testCategoricalColors',
116116
t,
117-
2,
117+
5,
118118
gc.releaseResources
119119
);
120120
});

Sources/Common/Core/LookupTable/test/testSetTable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ test.onlyIfWebGL('Test LookupTable setTable', (t) => {
138138
[baseline],
139139
'Common/Core/LookupTable/testSetTable',
140140
t,
141-
2,
141+
5,
142142
gc.releaseResources
143143
);
144144
});

Sources/Rendering/Core/ColorTransferFunction/test/testColorTransferFunction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ test('Test Color Transfer Function', (t) => {
114114
[baseline],
115115
'Rendering/Core/ColorTransferFunction/testColorTransferFunction',
116116
t,
117-
1.5,
117+
5,
118118
gc.releaseResources
119119
);
120120
});

Sources/Rendering/Core/HardwareSelector/test/testHardwareSelectorGlyph.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ test('Test HardwareSelectorGlyph', (tapeContext) => {
108108
sel.setFieldAssociation(FieldAssociations.FIELD_ASSOCIATION_POINTS);
109109

110110
sel.selectAsync(renderer, 200, 200, 250, 300).then((res) => {
111-
console.log(res);
112-
console.log(res[0].get());
113111
const allGood = res.length === 7 && res[0].getProperties().prop === actor;
114112

115113
tapeContext.ok(res.length === 7, 'Seven glyphs selected');

Sources/Rendering/Core/HardwareSelector/test/testHardwareSelectorSpeed.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ test('Test HardwareSelector', (tapeContext) => {
7676
const tcTime = Date.now() - previousTime;
7777
console.timeEnd('hardware render');
7878

79-
console.log(taTime, tbTime, tcTime);
80-
8179
tapeContext.ok(
8280
// should take about 3 normal renders but we give it some wiggle room
8381
tcTime < tbTime * 6,

Sources/Rendering/Core/ImageMapper/test/testImageColorTransferFunction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ test('Test ImageMapper Color TFun', (t) => {
7272
[baseline],
7373
'Rendering/Core/ImageMapper',
7474
t,
75-
1,
75+
5.0,
7676
gc.releaseResources
7777
);
7878
});

Sources/Rendering/Core/Mapper/test/testEdgeVisibility.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper';
1010

1111
import baseline from './testEdgeVisibility.png';
1212

13-
test('Test Edge Visibility', (t) => {
13+
test.skip('Test Edge Visibility', (t) => {
1414
const gc = testUtils.createGarbageCollector(t);
1515
t.ok('rendering', 'vtkMapper EdgeVisibility');
1616

@@ -50,7 +50,7 @@ test('Test Edge Visibility', (t) => {
5050
[baseline],
5151
'Rendering/Core/Mapper/testEdgeVisibility.js',
5252
t,
53-
5,
53+
1,
5454
gc.releaseResources
5555
);
5656
});

Sources/Rendering/Core/Mapper/test/testInterpolateScalarsBeforeMapping.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ test('Test Interpolate Scalars Before Mapping', (t) => {
109109
[baseline],
110110
'Rendering/Core/Mapper/testInterpolateScalarsBeforeMapping',
111111
t,
112-
1.5,
112+
5,
113113
gc.releaseResources
114114
);
115115
});

0 commit comments

Comments
 (0)