@@ -5,6 +5,7 @@ import { afterEach, beforeAll, describe, expect, test } from 'vitest'
55import { NodeFileSystem } from 'langium/node'
66import fs from 'node:fs'
77import path from 'node:path'
8+ import { fail } from 'node:assert'
89
910const outDir = path . join ( __dirname , 'out' )
1011
@@ -38,8 +39,12 @@ describe('Command execution tests', () => {
3839 test ( 'test plantUML command with invalid file extension' , async ( ) => {
3940 const file = path . join ( __dirname , '..' , 'invalid-files' , 'test.txt' )
4041
41- const result = await commandHandler . executeCommand ( 'org.contextmapper.GeneratePlantUML' , [ file , outDir ] )
42- expect ( result ) . toBeUndefined ( )
42+ try {
43+ await commandHandler . executeCommand ( 'org.contextmapper.GeneratePlantUML' , [ file , outDir ] )
44+ fail ( 'Expected generator to fail' )
45+ } catch ( e ) {
46+ expect ( e ) . not . toBeUndefined ( )
47+ }
4348
4449 const outContentExists = fs . existsSync ( outDir )
4550 expect ( outContentExists ) . toEqual ( false )
@@ -48,8 +53,12 @@ describe('Command execution tests', () => {
4853 test ( 'test plantUML command with invalid file' , async ( ) => {
4954 const file = path . join ( __dirname , '..' , 'invalid-files' , 'invalid.cml' )
5055
51- const result = await commandHandler . executeCommand ( 'org.contextmapper.GeneratePlantUML' , [ file , outDir ] )
52- expect ( result ) . toBeUndefined ( )
56+ try {
57+ await commandHandler . executeCommand ( 'org.contextmapper.GeneratePlantUML' , [ file , outDir ] )
58+ fail ( 'Expected generator to fail' )
59+ } catch ( e ) {
60+ expect ( e ) . not . toBeUndefined ( )
61+ }
5362
5463 const outContentExists = fs . existsSync ( outDir )
5564 expect ( outContentExists ) . toEqual ( false )
@@ -58,8 +67,12 @@ describe('Command execution tests', () => {
5867 test ( 'test plantUML command with non-existing file' , async ( ) => {
5968 const file = path . join ( __dirname , '..' , 'invalid-files' , 'non-existing.cml' )
6069
61- const result = await commandHandler . executeCommand ( 'org.contextmapper.GeneratePlantUML' , [ file , outDir ] )
62- expect ( result ) . toBeUndefined ( )
70+ try {
71+ await commandHandler . executeCommand ( 'org.contextmapper.GeneratePlantUML' , [ file , outDir ] )
72+ fail ( 'Expected generator to fail' )
73+ } catch ( e ) {
74+ expect ( e ) . not . toBeUndefined ( )
75+ }
6376
6477 const outContentExists = fs . existsSync ( outDir )
6578 expect ( outContentExists ) . toEqual ( false )
0 commit comments