-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #191 from Hargne/feature/a11y
Test Report a11y
- Loading branch information
Showing
13 changed files
with
648 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,4 @@ npm-debug.log | |
node_modules/ | ||
test-report/ | ||
dist/ | ||
test-report.html | ||
testResultsProcessorResult.html | ||
report.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,90 @@ | ||
#!/bin/sh | ||
|
||
JEST_VERSIONS=${JEST_VERSIONS:-"29"} # Default Jest versions | ||
|
||
# Echo the current Node version | ||
echo "Current Node version: $(node -v)" | ||
|
||
# Convert space-separated JEST_VERSIONS to an array | ||
# Create a jest config with properties we should test against | ||
FILENAME="test-report" | ||
PAGE_TITLE="A Title For This Report" | ||
|
||
for VERSION in $JEST_VERSIONS; do | ||
echo "Installing Jest version: $VERSION" | ||
npm install jest@$VERSION || exit 1 | ||
|
||
echo "Running tests with Jest version: $VERSION" | ||
yarn test --config=jest.config.json || exit 1 | ||
|
||
# Check if the output contains the expected text | ||
if grep -q "A Testresult Processor Title" ./testResultsProcessor.html; then | ||
echo "✅ Tests passed for Jest version: $VERSION" | ||
else | ||
echo "❌ Tests failed for Jest version: $VERSION" | ||
exit 1 | ||
fi | ||
# Extract the major version number | ||
MAJOR_VERSION=$(echo "$VERSION" | cut -d. -f1) | ||
|
||
# For Jest versions above 20 we use the reporters option | ||
if [ "$MAJOR_VERSION" -ge 20 ]; then | ||
cat <<EOF > jest.config.json || { echo "❌ Failed to create jest.config.json"; exit 1; } | ||
{ | ||
"testEnvironment": "node", | ||
"reporters": [ | ||
"default", | ||
["<rootDir>/jest-html-reporter", { | ||
"append": false, | ||
"boilerplate": null, | ||
"collapseSuitesByDefault": true, | ||
"customScriptPath": null, | ||
"dateFormat": "yyyy-mm-dd (HH:MM:ss)", | ||
"executionTimeWarningThreshold": 1, | ||
"includeConsoleLog": true, | ||
"includeFailureMsg": true, | ||
"includeStackTrace": true, | ||
"includeSuiteFailure": true, | ||
"logo": "https://placehold.co/100x50/png?text=Test+Report&font=playfair-display", | ||
"outputPath": "<rootDir>/${FILENAME}.html", | ||
"pageTitle": "${PAGE_TITLE}", | ||
"sort": "status", | ||
"statusIgnoreFilter": null, | ||
"styleOverridePath": "./style/defaultTheme.css", | ||
"useCssFile": true | ||
}] | ||
] | ||
} | ||
EOF | ||
else | ||
cat <<EOF > jest.config.json || { echo "❌ Failed to create jest.config.json"; exit 1; } | ||
{ | ||
"testEnvironment": "node", | ||
"testResultsProcessor": "<rootDir>/jest-html-reporter" | ||
} | ||
EOF | ||
cat <<EOF > jesthtmlreporter.config.json || { echo "❌ Failed to create jesthtmlreporter.config.json"; exit 1; } | ||
{ | ||
"append": false, | ||
"boilerplate": null, | ||
"collapseSuitesByDefault": true, | ||
"customScriptPath": null, | ||
"dateFormat": "yyyy-mm-dd (HH:MM:ss)", | ||
"executionTimeWarningThreshold": 1, | ||
"includeConsoleLog": true, | ||
"includeFailureMsg": true, | ||
"includeStackTrace": true, | ||
"includeSuiteFailure": true, | ||
"logo": "https://placehold.co/100x50/png?text=Test+Report&font=playfair-display", | ||
"outputPath": "<rootDir>/${FILENAME}.html", | ||
"pageTitle": "${PAGE_TITLE}", | ||
"sort": "status", | ||
"statusIgnoreFilter": null, | ||
"styleOverridePath": "./style/defaultTheme.css", | ||
"useCssFile": true | ||
} | ||
EOF | ||
fi | ||
|
||
echo "Installing Jest version: $VERSION" | ||
npm install jest@$VERSION || exit 1 | ||
|
||
echo "Running tests with Jest version: $VERSION" | ||
npm run test -- --config=jest.config.json || exit 1 | ||
|
||
# Check if the output contains the expected text | ||
if grep -q "$PAGE_TITLE" ./$FILENAME.html; then | ||
echo "✅ Tests passed for Jest version: $VERSION" | ||
else | ||
echo "❌ Tests failed for Jest version: $VERSION" | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "✅ All Jest versions passed!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
/** | ||
* This is only template tests used for testing the | ||
* implementation jest-html-reporter together with Jest | ||
*/ | ||
|
||
const { add, subtract } = require("./index"); | ||
|
||
test("adds 1 + 2 to equal 3", () => { | ||
expect(add(1, 2)).toBe(3); | ||
}); | ||
describe("test-project", () => { | ||
test("adds 1 + 2 to equal 3", () => { | ||
expect(add(1, 2)).toBe(3); | ||
}); | ||
|
||
test("subtracts 5 - 3 to equal 2", () => { | ||
expect(subtract(5, 3)).toBe(2); | ||
}); | ||
}) | ||
|
||
test("subtracts 5 - 3 to equal 2", () => { | ||
expect(subtract(5, 3)).toBe(2); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,5 +18,6 @@ | |
"statements": 75 | ||
} | ||
}, | ||
"testEnvironment": "jsdom", | ||
"verbose": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.