|
| 1 | +'use strict'; |
| 2 | +const { run } = require('../../utils/test-utils'); |
| 3 | +const { stat } = require('fs'); |
| 4 | +const { resolve } = require('path'); |
| 5 | +describe('mode flags', () => { |
| 6 | + it('should load a production config when --prod is passed', done => { |
| 7 | + const { stderr, stdout } = run(__dirname, ['--prod']); |
| 8 | + expect(stderr).toBeFalsy(); |
| 9 | + expect(stdout).toBeTruthy(); |
| 10 | + stat(resolve(__dirname, './bin/main.js'), (err, stats) => { |
| 11 | + expect(err).toBe(null); |
| 12 | + expect(stats.isFile()).toBe(true); |
| 13 | + done(); |
| 14 | + }); |
| 15 | + }); |
| 16 | + |
| 17 | + it('should load a production config when --mode=production is passed', done => { |
| 18 | + const { stderr, stdout } = run(__dirname, ['--mode', 'production']); |
| 19 | + expect(stderr).toBeFalsy(); |
| 20 | + expect(stdout).toBeTruthy(); |
| 21 | + stat(resolve(__dirname, './bin/main.js'), (err, stats) => { |
| 22 | + expect(err).toBe(null); |
| 23 | + expect(stats.isFile()).toBe(true); |
| 24 | + done(); |
| 25 | + }); |
| 26 | + }); |
| 27 | + |
| 28 | + it('should load a production config when --mode=production and --prod are passed', done => { |
| 29 | + const { stderr, stdout } = run(__dirname, ['--mode', 'production', '--prod']); |
| 30 | + expect(stderr).toContain('"mode" will be used'); |
| 31 | + expect(stdout).toBeTruthy(); |
| 32 | + |
| 33 | + stat(resolve(__dirname, './bin/main.js'), (err, stats) => { |
| 34 | + expect(err).toBe(null); |
| 35 | + expect(stats.isFile()).toBe(true); |
| 36 | + done(); |
| 37 | + }); |
| 38 | + }); |
| 39 | + |
| 40 | + it('should load a production config when --mode=production and --dev are passed', done => { |
| 41 | + const { stderr, stdout } = run(__dirname, ['--mode', 'production', '--dev']); |
| 42 | + expect(stderr).toContain('"mode" will be used'); |
| 43 | + expect(stdout).toBeTruthy(); |
| 44 | + |
| 45 | + stat(resolve(__dirname, './bin/main.js'), (err, stats) => { |
| 46 | + expect(err).toBe(null); |
| 47 | + expect(stats.isFile()).toBe(true); |
| 48 | + done(); |
| 49 | + }); |
| 50 | + }); |
| 51 | + |
| 52 | + it('should load a production config when passing --dev and --prod', done => { |
| 53 | + const { stderr, stdout } = run(__dirname, ['--prod', '--dev']); |
| 54 | + expect(stderr).toBeFalsy(); |
| 55 | + expect(stdout).toBeTruthy(); |
| 56 | + |
| 57 | + stat(resolve(__dirname, './bin/main.js'), (err, stats) => { |
| 58 | + expect(err).toBe(null); |
| 59 | + expect(stats.isFile()).toBe(true); |
| 60 | + done(); |
| 61 | + }); |
| 62 | + }); |
| 63 | +}); |
0 commit comments