|
| 1 | +/* |
| 2 | + * This file is part of the Symfony package. |
| 3 | + * |
| 4 | + * (c) Fabien Potencier <[email protected]> |
| 5 | + * |
| 6 | + * For the full copyright and license information, please view the LICENSE |
| 7 | + * file that was distributed with this source code. |
| 8 | + */ |
| 9 | + |
| 10 | +'use strict'; |
| 11 | + |
| 12 | +const chai = require('chai'); |
| 13 | +chai.use(require('chai-fs')); |
| 14 | +const path = require('path'); |
| 15 | +const testSetup = require('../../lib/test/setup'); |
| 16 | +const fs = require('fs-extra'); |
| 17 | +const exec = require('child_process').exec; |
| 18 | + |
| 19 | +describe('bin/encore.js', function() { |
| 20 | + // being functional tests, these can take quite long |
| 21 | + this.timeout(8000); |
| 22 | + |
| 23 | + it('Basic smoke test', (done) => { |
| 24 | + testSetup.emptyTmpDir(); |
| 25 | + const testDir = testSetup.createTestAppDir(); |
| 26 | + |
| 27 | + fs.writeFileSync( |
| 28 | + path.join(testDir, 'webpack.config.js'), |
| 29 | + ` |
| 30 | +const Encore = require('../../index.js'); |
| 31 | +Encore |
| 32 | + .setOutputPath('build/') |
| 33 | + .setPublicPath('/build') |
| 34 | + .addEntry('main', './js/no_require') |
| 35 | +; |
| 36 | +
|
| 37 | +module.exports = Encore.getWebpackConfig(); |
| 38 | + ` |
| 39 | + ); |
| 40 | + |
| 41 | + const binPath = path.resolve(__dirname, '../', '../', 'bin', 'encore.js'); |
| 42 | + exec(`node ${binPath} dev --context=${testDir}`, { cwd: testDir }, (err, stdout, stderr) => { |
| 43 | + if (err) { |
| 44 | + throw new Error(`Error executing encore: ${err} ${stderr} ${stdout}`); |
| 45 | + } |
| 46 | + |
| 47 | + done(); |
| 48 | + }); |
| 49 | + }); |
| 50 | +}); |
0 commit comments