@@ -2,6 +2,7 @@ import anyTest, {TestFn} from "ava";
22import * as sinon from "sinon" ;
33import esmock from "esmock" ;
44import { readFile } from "fs/promises" ;
5+ import { InvalidInputError } from "../../../../src/utils.js" ;
56
67const test = anyTest as TestFn < {
78 sinon : sinon . SinonSandbox ;
@@ -136,17 +137,27 @@ test("runValidation successfully validates invalid manifest", async (t) => {
136137 } ) ;
137138} ) ;
138139
140+ test ( "runValidation throws error when manifest file path is not absolute" , async ( t ) => {
141+ const { runValidation} = t . context ;
142+
143+ await t . throwsAsync ( async ( ) => {
144+ return await runValidation ( "relativeManifest.json" ) ;
145+ } , {
146+ instanceOf : InvalidInputError ,
147+ message : "The manifest path must be absolute: 'relativeManifest.json'" ,
148+ } ) ;
149+ } ) ;
150+
139151test ( "runValidation throws error when manifest file path is not correct" , async ( t ) => {
140152 const { runValidation, readFileStub} = t . context ;
141153
142154 // Stub the readFile function to throw an error
143155 readFileStub . rejects ( new Error ( "File not found" ) ) ;
144156
145157 await t . throwsAsync ( async ( ) => {
146- const result = await runValidation ( "/nonexistent/path" ) ;
147- return result ;
158+ return await runValidation ( "/nonexistent/path" ) ;
148159 } , {
149- instanceOf : Error ,
160+ instanceOf : InvalidInputError ,
150161 message : / F a i l e d t o r e a d m a n i f e s t f i l e a t .+ : .+ / ,
151162 } ) ;
152163} ) ;
@@ -157,10 +168,9 @@ test("runValidation throws error when manifest file content is invalid JSON", as
157168 t . context . manifestFileContent = "Invalid JSON Content" ;
158169
159170 await t . throwsAsync ( async ( ) => {
160- const result = await runValidation ( "/path/to/manifest.json" ) ;
161- return result ;
171+ return await runValidation ( "/path/to/manifest.json" ) ;
162172 } , {
163- instanceOf : Error ,
173+ instanceOf : InvalidInputError ,
164174 message : / F a i l e d t o p a r s e m a n i f e s t f i l e a t .+ a s J S O N : .+ / ,
165175 } ) ;
166176} ) ;
@@ -172,8 +182,7 @@ test("runValidation throws error when schema validation function cannot be compi
172182 getManifestSchemaStub . resolves ( null ) ; // Simulate invalid schema
173183
174184 await t . throwsAsync ( async ( ) => {
175- const result = await runValidation ( "/path/to/manifest.json" ) ;
176- return result ;
185+ return await runValidation ( "/path/to/manifest.json" ) ;
177186 } , {
178187 instanceOf : Error ,
179188 message : / F a i l e d t o c r e a t e U I 5 m a n i f e s t v a l i d a t e f u n c t i o n : .+ / ,
@@ -247,8 +256,7 @@ test("runValidation throws error when external schema cannot be fetched", async
247256 . rejects ( new Error ( "Failed to fetch external schema" ) ) ;
248257
249258 await t . throwsAsync ( async ( ) => {
250- const result = await runValidation ( "/path/to/manifest.json" ) ;
251- return result ;
259+ return await runValidation ( "/path/to/manifest.json" ) ;
252260 } , {
253261 instanceOf : Error ,
254262 message : / F a i l e d t o c r e a t e U I 5 m a n i f e s t v a l i d a t e f u n c t i o n : .+ / ,
0 commit comments