Skip to content

Commit ce331e2

Browse files
committed
test: update unreliable tests
1 parent 63dc53c commit ce331e2

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed

tests/__snapshots__/code_transformer.spec.ts.cjs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,43 @@ export const middleware = router.named({
314314
})
315315
"`
316316

317+
exports[`Code transformer | addCommand > add command to rc file 1`] = `"import { defineConfig } from '@adonisjs/core/app'
318+
319+
export default defineConfig({
320+
typescript: true,
321+
preloads: [
322+
() => import('./start/routes.ts'),
323+
{
324+
file: () => import('./start/ace.ts'),
325+
environment: ['console'],
326+
},
327+
],
328+
providers: [
329+
() => import('@adonisjs/core/providers/app_provider'),
330+
{
331+
file: () => import('@adonisjs/core/providers/repl_provider'),
332+
environment: ['repl'],
333+
}
334+
],
335+
metaFiles: [
336+
{
337+
pattern: 'public/**',
338+
reloadServer: true
339+
},
340+
],
341+
commands: [
342+
() => import('@adonisjs/core/commands'),
343+
() => import('#foo/bar.js'),
344+
() => import('#foo/bar2.js')
345+
]
346+
})
347+
"`
348+
349+
exports[`Code transformer | addCommand > should add command even if commands property is missing 1`] = `"import { defineConfig } from '@adonisjs/core/app'
350+
351+
export default defineConfig({
352+
typescript: true,
353+
commands: [() => import('#foo/bar.js')]
354+
})
355+
"`
356+

tests/code_transformer.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ test.group('Code transformer | addCommand', (group) => {
188188
rcFile.addCommand('#foo/bar.js').addCommand('#foo/bar2.js')
189189
})
190190

191-
assert.fileContains('adonisrc.ts', `() => import('#foo/bar.js')`)
192-
assert.fileContains('adonisrc.ts', `() => import('#foo/bar2.js')`)
191+
const file = await fs.contents('adonisrc.ts')
192+
assert.snapshot(file).match()
193193
})
194194

195195
test('add command should not add duplicate', async ({ assert, fs }) => {
@@ -222,7 +222,8 @@ test.group('Code transformer | addCommand', (group) => {
222222
rcFile.addCommand('#foo/bar.js')
223223
})
224224

225-
assert.fileContains('adonisrc.ts', `() => import('#foo/bar.js')`)
225+
const file = await fs.contents('adonisrc.ts')
226+
assert.snapshot(file).match()
226227
})
227228
})
228229

0 commit comments

Comments
 (0)