1- const { lintSchemas } = require ( '../src/schemas/lintSchemas' ) ;
2- const assert = require ( 'assert' ) ;
1+ const { exec } = require ( 'child_process' ) ;
32const path = require ( 'path' ) ;
3+ const assert = require ( 'assert' ) ;
44
55describe ( 'Spectral schema linting' , function ( ) {
66 // This test may take longer to run, especially with many schemas
77 this . timeout ( 10000 ) ;
88
9- it ( 'should validate v3 schemas' , async function ( ) {
10- try {
11- const results = await lintSchemas ( {
12- schemasDir : path . resolve ( `${ __dirname } /../src/schemas/src_schemas` ) ,
13- rulesetPath : path . resolve ( `${ __dirname } /../.spectral.yaml` ) ,
14- v3Only : true
15- } ) ;
16-
17- console . log ( "Schema linting completed" ) ;
18-
19- // This test always passes for now, until we're ready to enforce rules
20- assert . ok ( true ) ;
21- } catch ( error ) {
22- // For now, we don't fail the test if there's an error with Spectral setup
23- console . log ( `Schema linting error: ${ error . message } ` ) ;
24- console . log ( "Continuing with tests - spectral errors will be addressed separately" ) ;
25- assert . ok ( true ) ;
26- }
9+ it ( 'should validate v3 schemas and report issues' , function ( done ) {
10+ const spectralCmd = path . resolve ( `${ __dirname } /../node_modules/.bin/spectral` ) ;
11+ const rulesetPath = path . resolve ( `${ __dirname } /../.spectral.yaml` ) ;
12+ const schemaPath = path . resolve ( `${ __dirname } /../src/schemas/src_schemas/*_v3.schema.json` ) ;
13+
14+ exec ( `${ spectralCmd } lint -r ${ rulesetPath } "${ schemaPath } " --format json` , ( error , stdout ) => {
15+ // We still want to run the test even if there are errors
16+ // But we want to log the issues for visibility
17+ try {
18+ const issues = JSON . parse ( stdout ) ;
19+ console . log ( `Schema linting found ${ issues . length } issues` ) ;
20+
21+ // Count errors vs warnings
22+ const errors = issues . filter ( issue => issue . severity === 0 ) . length ;
23+ const warnings = issues . filter ( issue => issue . severity === 1 ) . length ;
24+
25+ console . log ( `- ${ errors } errors` ) ;
26+ console . log ( `- ${ warnings } warnings` ) ;
27+
28+ // For now, just show we ran the linting but don't fail
29+ // In future PRs, errors should be addressed
30+ assert . ok ( true , 'Schema linting completed' ) ;
31+ done ( ) ;
32+ } catch ( parseError ) {
33+ console . error ( 'Error parsing spectral output:' , parseError ) ;
34+ done ( ) ;
35+ }
36+ } ) ;
2737 } ) ;
2838} ) ;
0 commit comments