diff --git a/.npmignore b/.npmignore index 273f668..5ca44bd 100644 --- a/.npmignore +++ b/.npmignore @@ -6,3 +6,4 @@ tests/ *.log .env tsconfig.json +*.config.ts diff --git a/src/index.ts b/src/index.ts index 33af8a5..408f15f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,9 +24,14 @@ const enabled = Object.values(agents).some((agent) => agent); export default class CustomReporter implements Reporter { private outputFile: string; - onInit(ctx: Vitest): void { + async onInit(ctx: Vitest) { if (!enabled) return; + console.log('Custom reporter enabled. Using these agents:'); + for (const [agent, available] of Object.entries(agents)) { + if (available) console.log(` - ${agent}`); + } + this.outputFile = (typeof ctx.config.outputFile === 'string' ? ctx.config.outputFile : ctx.config.outputFile?.html @@ -42,9 +47,9 @@ export default class CustomReporter implements Reporter { fs.rmSync(this.outputFile, { recursive: true, force: true }); } else console.log('HTML reporter not enabled.'); - console.log('Custom reporter enabled. Using these agents:'); - for (const [agent, available] of Object.entries(agents)) { - if (available) console.log(` - ${agent}`); + if (notionAvailable) { + console.log('Setting up Notion database...'); + await setupNotionDatabases(); } } @@ -57,9 +62,6 @@ export default class CustomReporter implements Reporter { let changes: Changes | undefined; if (notionAvailable) { - console.log('Setting up Notion database...'); - await setupNotionDatabases(); - console.log('Updating Notion database...'); changes = await updateNotionTestsDB(files); } else console.log('No Notion config provided. Skipping update.'); diff --git a/src/notion/NotionDatabase.ts b/src/notion/NotionDatabase.ts index af810ad..8b6ccbb 100644 --- a/src/notion/NotionDatabase.ts +++ b/src/notion/NotionDatabase.ts @@ -357,6 +357,7 @@ export default class NotionDatabase { ]) => { if (!tablePropsTypes[propName]) return { propName: propName, + requiredType: requiredPropType, issue: 'missing', }; @@ -371,6 +372,7 @@ export default class NotionDatabase { }).filter((issue) => issue !== null) as ( { propName: PropertyName; + requiredType: PropertyType; issue: 'missing'; } | { propName: PropertyName; @@ -384,7 +386,7 @@ export default class NotionDatabase { logger.error([ ' Invalid schema:', ...issues.map((issue) => { - if (issue.issue === 'missing') return ` - Missing property '${issue.propName}'`; + if (issue.issue === 'missing') return ` - Missing property '${issue.propName}' (type: ${issue.requiredType}))`; return ` - Invalid type for property '${issue.propName}': expected '${issue.requiredType}', got '${issue.propType}'`; }), ].join('\n'));