@@ -3,6 +3,7 @@ const expect = require('expect.js');
33const Support = require ( __dirname + '/../support' ) ;
44const helpers = require ( __dirname + '/../support/helpers' ) ;
55const gulp = require ( 'gulp' ) ;
6+ const semver = require ( 'semver' ) ;
67const _ = require ( 'lodash' ) ;
78
89[
@@ -293,6 +294,54 @@ describe(Support.getTestDialectTeaser('db:migrate'), () => {
293294 } ) ;
294295} ) ;
295296
297+ describeOnlyForESM ( Support . getTestDialectTeaser ( 'db:migrate' ) , ( ) => {
298+ describe ( 'with config.mjs' , ( ) => {
299+ const prepare = function ( callback ) {
300+ const config = helpers . getTestConfig ( ) ;
301+ const configContent = 'export default ' + JSON . stringify ( config ) ;
302+ let result = '' ;
303+
304+ return gulp
305+ . src ( Support . resolveSupportPath ( 'tmp' ) )
306+ . pipe ( helpers . clearDirectory ( ) )
307+ . pipe ( helpers . runCli ( 'init' ) )
308+ . pipe ( helpers . removeFile ( 'config/config.json' ) )
309+ . pipe ( helpers . copyMigration ( 'createPerson.js' ) )
310+ . pipe ( helpers . overwriteFile ( configContent , 'config/config.mjs' ) )
311+ . pipe ( helpers . runCli ( 'db:migrate --config config/config.mjs' ) )
312+ . on ( 'error' , ( e ) => {
313+ callback ( e ) ;
314+ } )
315+ . on ( 'data' , ( data ) => {
316+ result += data . toString ( ) ;
317+ } )
318+ . on ( 'end' , ( ) => {
319+ callback ( null , result ) ;
320+ } ) ;
321+ } ;
322+
323+ it ( 'creates a SequelizeMeta table' , function ( done ) {
324+ prepare ( ( ) => {
325+ helpers . readTables ( this . sequelize , ( tables ) => {
326+ expect ( tables ) . to . have . length ( 2 ) ;
327+ expect ( tables ) . to . contain ( 'SequelizeMeta' ) ;
328+ done ( ) ;
329+ } ) ;
330+ } ) ;
331+ } ) ;
332+
333+ it ( 'creates the respective table' , function ( done ) {
334+ prepare ( ( ) => {
335+ helpers . readTables ( this . sequelize , ( tables ) => {
336+ expect ( tables ) . to . have . length ( 2 ) ;
337+ expect ( tables ) . to . contain ( 'Person' ) ;
338+ done ( ) ;
339+ } ) ;
340+ } ) ;
341+ } ) ;
342+ } ) ;
343+ } ) ;
344+
296345describe ( Support . getTestDialectTeaser ( 'db:migrate' ) , ( ) => {
297346 describe ( 'with config.json and url option' , ( ) => {
298347 const prepare = function ( callback ) {
@@ -525,3 +574,11 @@ describe(Support.getTestDialectTeaser('db:migrate'), () => {
525574 } ) ;
526575 } ) ;
527576} ) ;
577+
578+ function describeOnlyForESM ( title , fn ) {
579+ if ( semver . satisfies ( process . version , '^12.20.0 || ^14.13.1 || >=16.0.0' ) ) {
580+ describe ( title , fn ) ;
581+ } else {
582+ describe . skip ( title , fn ) ;
583+ }
584+ }
0 commit comments