atdatabases
atdatabases copied to clipboard
migrationsScript property not working with a string
Hi,
When I run my tests, I received this error:
Error: MySqlConfig.test.migrationsScript should be array
packaged.json config:
"mysql": {
"test": {
"migrationsScript": "npm run db:migrate"
}
}
If I change to Array:
"migrationsScript": [ "npm run db:migrate" ]
I received this:
Error: spawn npm run db:migrate ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
In the file node_modules/@databases/mysql-config/lib/MySqlConfig.validator.js has this validation:
migrationsScript: {
description: 'Optional script to run after the database\nhas been started but before running tests',
items: {
type: 'string'
},
type: 'array'
},
But in the @databases/[email protected] TAG has this:
migrationsScript: {
anyOf: [
{
items: {
type: 'string',
},
type: 'array',
},
{
type: 'string',
},
],
description:
'Optional script to run after the database\nhas been started but before running tests',
}
"@databases/mysql-test": "^2.0.0" Node: v12.18.4 NPM: 6.14.6
It's working with:
"mysql": {
"test": {
"migrationsScript": [
"npm",
"run",
"db:migrate"
]
}
}
This needs updating in the documentation to show using an array. Using an array is much more reliable than using a string would be, so it makes sense to prefer this approach.