Skip to content

Commit fd8944c

Browse files
committed
test: fix breaking assertions after using kernel.errorHandler
1 parent 4c61de9 commit fd8944c

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

commands/configure.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import { stubsRoot } from '../stubs/main.js'
1111
import type { CommandOptions } from '../types/ace.js'
1212
import { args, BaseCommand, flags } from '../modules/ace/main.js'
13+
import { RuntimeException } from '@poppinss/utils'
1314

1415
/**
1516
* The configure command is used to configure packages after installation
@@ -165,6 +166,12 @@ export default class Configure extends BaseCommand {
165166
/**
166167
* Run instructions
167168
*/
168-
await packageExports.configure(this)
169+
try {
170+
await packageExports.configure(this)
171+
} catch (error) {
172+
throw new RuntimeException(`Unable to configure package "${this.name}"`, {
173+
cause: error,
174+
})
175+
}
169176
}
170177
}

tests/ace/base_command.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ test.group('Base command', () => {
112112

113113
const kernel = createAceKernel(app)
114114
kernel.ui.switchMode('raw')
115+
kernel.errorHandler.render = async function (error: Error) {
116+
command.logger.fatal(error)
117+
}
115118

116119
const command = await kernel.create(MakeController, [])
117120
await command.exec()
@@ -137,6 +140,9 @@ test.group('Base command', () => {
137140

138141
const kernel = createAceKernel(app)
139142
kernel.ui.switchMode('raw')
143+
kernel.errorHandler.render = async function (error: Error) {
144+
command.logger.fatal(error)
145+
}
140146

141147
const command = await kernel.create(MakeController, [])
142148
await command.exec()
@@ -162,6 +168,9 @@ test.group('Base command', () => {
162168

163169
const kernel = createAceKernel(app)
164170
kernel.ui.switchMode('raw')
171+
kernel.errorHandler.render = async function (error: Error) {
172+
command.logger.fatal(error)
173+
}
165174

166175
const command = await kernel.create(MakeController, [])
167176
await command.exec()
@@ -219,6 +228,9 @@ test.group('Base command', () => {
219228

220229
const kernel = createAceKernel(app)
221230
kernel.ui.switchMode('raw')
231+
kernel.errorHandler.render = async function (error: Error) {
232+
command.logger.fatal(error)
233+
}
222234

223235
const command = await kernel.create(MakeController, [])
224236
await command.exec()

tests/commands/add.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,14 @@ test.group('Install', (group) => {
278278

279279
const command = await ace.create(Add, [new URL('node_modules/foo', fs.baseUrl).href])
280280
command.verbose = VERBOSE
281+
ace.errorHandler.render = async function (error: Error) {
282+
command.logger.fatal(error)
283+
}
281284

282285
await command.exec()
283286

284287
command.assertExitCode(1)
285-
command.assertLogMatches(/Invalid configure/)
288+
command.assertLogMatches(/Unable to configure/)
286289
})
287290

288291
test('configure edge', async ({ assert, fs }) => {

0 commit comments

Comments
 (0)