Skip to content

Commit

Permalink
chore(importer): catch syntax errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jlenon7 committed Oct 10, 2024
1 parent 72a7820 commit 0eabbf8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/test",
"version": "5.0.0",
"version": "5.1.0",
"description": "The Athenna test runner. Built on top of Japa.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down
32 changes: 21 additions & 11 deletions src/helpers/Importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,30 @@ export class Importer {
* Import some japa test file and resolve the that class if exists.
*/
public static async import(fileUrl: URL) {
const Test = await Module.getFrom(fileUrl.href)
try {
const Test = await Module.getFrom(fileUrl.href)

if (!Test) {
const fileName = parse(fileUrl.href).name
if (!Test) {
const fileName = parse(fileUrl.href).name
debug(
'skipping class registration of %s file. there is no class being exported at %s path.',
fileName,
fileUrl.href
)
return
}

debug(
'skipping class registration of %s file. there is no class being exported at %s path.',
fileName,
fileUrl.href
)
new TestConverter(Test).registerGroup()
} catch (err) {
if (!err.message) {
console.error(
`Error while importing ${parse(fileUrl.href).name}:\n`,
err
)
process.exit(1)
}

return
throw err
}

new TestConverter(Test).registerGroup()
}
}

0 comments on commit 0eabbf8

Please sign in to comment.