-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Skipping failed tests from JSON-Schema-Test-Suite
We'll re-enable them once the feature is implemented. feat: Skipping failed tests from JSON-Schema-Test-Suite We'll re-enable them once the feature is implemented. fix: typo fix: typo
- Loading branch information
1 parent
00e81ec
commit 0728e56
Showing
6 changed files
with
680 additions
and
2 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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export const JSON_SCHEMA_SUITE_FAILED_TESTS_FILE = 'failed-json-schema-test-suite.json' |
582 changes: 582 additions & 0 deletions
582
next/test/validation/failed-json-schema-test-suite.json
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import fs from 'node:fs' | ||
import path from 'node:path' | ||
import { JSON_SCHEMA_SUITE_FAILED_TESTS_FILE } from './constants' | ||
|
||
export function loadJsonSchemaSuiteFailedTests(): string[] { | ||
try { | ||
const content = fs.readFileSync(path.join(__dirname, JSON_SCHEMA_SUITE_FAILED_TESTS_FILE), 'utf8') | ||
return JSON.parse(content).failedTests | ||
} | ||
catch (error) { | ||
console.error('An error occurred when loading the file with failed tests:', error) | ||
return [] | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import fs from 'node:fs' | ||
import path from 'node:path' | ||
import { fileURLToPath } from 'node:url' | ||
|
||
import { JSON_SCHEMA_SUITE_FAILED_TESTS_FILE } from './constants.js' | ||
|
||
const __filename = fileURLToPath(import.meta.url) | ||
const __dirname = path.dirname(__filename) | ||
|
||
// Change this value to true to write the failed tests to a file, for | ||
// later consumption at the json_schema_test_suite.test.js file. | ||
const SHOULD_WRITE_FAILED_TESTS_TO_FILE = false | ||
|
||
// Save newly failed tests | ||
function saveFailedTests(failedTests) { | ||
fs.writeFileSync(path.join(__dirname, JSON_SCHEMA_SUITE_FAILED_TESTS_FILE), JSON.stringify({ failedTests }, null, 2)) | ||
} | ||
|
||
/** | ||
* On top of our test cases, we're running the JSON-Schema-Test-Suite | ||
* (https://github.com/json-schema-org/JSON-Schema-Test-Suite/tree/main/tests/draft2020-12). | ||
* However, until all features are implemented, some of the | ||
* tests in this suite would fail. We're using this reporter to keep track of the | ||
* tests that are failing (on the JSON_SCHEMA_SUITE_FAILED_TESTS_FILE), so we | ||
* can re-enable them once the feature is implemented. | ||
* | ||
* Note: The failed tests are not being saved to file every time the suite runs, | ||
* as this could cause for bugs to surface due to a change in the codebase. | ||
* The SHOULD_WRITE_FAILED_TESTS_TO_FILE constant can be set to true to write the | ||
* failed tests to a file (on-demand), for later consumption at the | ||
* json_schema_test_suite.test.js file. | ||
* | ||
*/ | ||
class FailureTrackingReporter { | ||
constructor() { | ||
this.failedTests = new Set() | ||
} | ||
|
||
onTestResult(test, testResult) { | ||
testResult.testResults.forEach((result) => { | ||
if (result.status === 'failed') { | ||
this.failedTests.add(result.fullName || result.title) | ||
} | ||
}) | ||
} | ||
|
||
onRunComplete() { | ||
if (SHOULD_WRITE_FAILED_TESTS_TO_FILE) { | ||
saveFailedTests(Array.from(this.failedTests)) | ||
} | ||
} | ||
} | ||
|
||
export default FailureTrackingReporter |