Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
node_modules/
report.json
15 changes: 13 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,18 @@ jobs:
- uses: actions/checkout@v4

- name: Start containers
run: docker compose up -d
run: docker compose -f docker-compose.ci.yml up -d

# install any dependencies since this is a fresh checkout
- name: Install dependencies
run: docker compose -f docker-compose.ci.yml run -v ${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE} --workdir ${GITHUB_WORKSPACE} tests yarn install

- name: Run tests
run: docker compose run tests jest --coverage
run: docker compose -f docker-compose.ci.yml run -v ${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE} --workdir ${GITHUB_WORKSPACE} tests jest --coverage --ci --json --testLocationInResults --outputFile=report.json

- name: Collect test coverage
uses: ArtiomTr/jest-coverage-report-action@v2
if: always() # we should still try to run this even if there are test failures
with:
coverage-file: ./report.json
base-coverage-file: ./report.json
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
node_modules/
report.json
7 changes: 7 additions & 0 deletions docker-compose.ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
tests:
extends:
file: "docker-compose.yml"
service: tests
build:
target: base # do not install dependencies because we will mount a fresh checkout
7 changes: 6 additions & 1 deletion sum.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
function sum(a, b) {
return a + b;
}
module.exports = sum;

function multiply(a, b) {

Check warning on line 5 in sum.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
return a * b;

Check warning on line 6 in sum.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

module.exports = sum;
6 changes: 5 additions & 1 deletion sum.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

test('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3);
});
});

test('adds 1 + 2 to equal 4', () => {

Check failure on line 7 in sum.test.js

View workflow job for this annotation

GitHub Actions / Tests annotations (🧪 jest-coverage-report-action)

adds 1 + 2 to equal 4

Error: expect(received).toBe(expected) // Object.is equality Expected: 4 Received: 3 at Object.toBe (/home/runner/work/docker-annotations-test/docker-annotations-test/sum.test.js:8:21) at Promise.finally.completed (/home/runner/work/docker-annotations-test/docker-annotations-test/node_modules/jest-circus/build/jestAdapterInit.js:1559:28) at new Promise (<anonymous>) at callAsyncCircusFn (/home/runner/work/docker-annotations-test/docker-annotations-test/node_modules/jest-circus/build/jestAdapterInit.js:1499:10) at _callCircusTest (/home/runner/work/docker-annotations-test/docker-annotations-test/node_modules/jest-circus/build/jestAdapterInit.js:1009:40) at processTicksAndRejections (node:internal/process/task_queues:105:5) at _runTest (/home/runner/work/docker-annotations-test/docker-annotations-test/node_modules/jest-circus/build/jestAdapterInit.js:949:3) at _runTestsForDescribeBlock (/home/runner/work/docker-annotations-test/docker-annotations-test/node_modules/jest-circus/build/jestAdapterInit.js:839:13) at run (/home/runner/work/docker-annotations-test/docker-annotations-test/node_modules/jest-circus/build/jestAdapterInit.js:757:3) at runAndTransformResultsToJestFormat (/home/runner/work/docker-annotations-test/docker-annotations-test/node_modules/jest-circus/build/jestAdapterInit.js:1920:21) at jestAdapter (/home/runner/work/docker-annotations-test/docker-annotations-test/node_modules/jest-circus/build/runner.js:101:19) at runTestInternal (/home/runner/work/docker-annotations-test/docker-annotations-test/node_modules/jest-runner/build/index.js:275:16) at runTest (/home/runner/work/docker-annotations-test/docker-annotations-test/node_modules/jest-runner/build/index.js:343:7)
expect(sum(1, 2)).toBe(4);
});
Loading