diff --git a/.gitignore b/.gitignore index 389f7a04..6316f30e 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,6 @@ coverage scripts/tmp -src/testdata/diff_* +tests/testdata/diff_* cache \ No newline at end of file diff --git a/README.md b/README.md index 03daf4be..a03fd27e 100644 --- a/README.md +++ b/README.md @@ -135,9 +135,9 @@ This will launch a Grafana instance in Docker and, then, run the test suites. _Notes:_ -If there are some expected changes in the reference image files (located in `/src/testdata`), run `yarn test-update` and push the updated references. +If there are some expected changes in the reference image files (located in `/tests/testdata`), run `yarn test-update` and push the updated references. -If the tests are failing and you want to see the difference between the image you get and the reference image, run `yarn test-diff`. This will generate images (called `diff_.png`) containing the differences in the `/src/testdata` folder. +If the tests are failing and you want to see the difference between the image you get and the reference image, run `yarn test-diff`. This will generate images (called `diff_.png`) containing the differences in the `/tests/testdata` folder. ### Fixing Drone issues diff --git a/jest.config.js b/jest.config.js index b413e106..79ca57a1 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,4 +2,5 @@ module.exports = { preset: 'ts-jest', testEnvironment: 'node', + reporters: ['/tests/reporter.js'], }; \ No newline at end of file diff --git a/src/service/http-server.integration.test.ts b/src/service/http-server.integration.test.ts index e1fae171..8a415344 100644 --- a/src/service/http-server.integration.test.ts +++ b/src/service/http-server.integration.test.ts @@ -29,7 +29,7 @@ const renderKey = jwt.sign( { algorithm: 'HS512' } ); -const goldenFilesFolder = './src/testdata'; +const goldenFilesFolder = './tests/testdata'; const serviceConfig: ServiceConfig = { service: { host: undefined, diff --git a/tests/reporter.js b/tests/reporter.js new file mode 100644 index 00000000..b522dfa7 --- /dev/null +++ b/tests/reporter.js @@ -0,0 +1,25 @@ +const { DefaultReporter } = require('@jest/reporters') + +class Reporter extends DefaultReporter +{ + constructor() + { + super(...arguments) + } + + printTestFileHeader(_testPath, config, result) + { + const console = result.console + + if(result.numFailingTests === 0 && !result.testExecError) + { + result.console = null + } + + super.printTestFileHeader(...arguments) + + result.console = console + } +} + +module.exports = Reporter \ No newline at end of file diff --git a/src/testdata/error.png b/tests/testdata/error.png similarity index 100% rename from src/testdata/error.png rename to tests/testdata/error.png diff --git a/src/testdata/graph.png b/tests/testdata/graph.png similarity index 100% rename from src/testdata/graph.png rename to tests/testdata/graph.png diff --git a/src/testdata/table.png b/tests/testdata/table.png similarity index 100% rename from src/testdata/table.png rename to tests/testdata/table.png