-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#936: Add failing test for copy files persistent cache manifest key bug
- Loading branch information
1 parent
972c882
commit ac91584
Showing
5 changed files
with
238 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* This file is part of the Symfony Webpack Encore package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const chai = require('chai'); | ||
chai.use(require('chai-fs')); | ||
chai.use(require('chai-subset')); | ||
const path = require('path'); | ||
const testSetup = require('../helpers/setup'); | ||
|
||
function createWebpackConfig(outputDirName = '', testName, command, argv = {}) { | ||
// We need a static named test dir for the cache to work | ||
let testAppDir = testSetup.createTestAppDir(null, testName + '/test'); | ||
const webpackConfig = testSetup.createWebpackConfig( | ||
testAppDir, | ||
outputDirName, | ||
command, | ||
argv, | ||
); | ||
|
||
webpackConfig.enableSingleRuntimeChunk(); | ||
webpackConfig.enableBuildCache({ config: [__filename] }, (cache) => { | ||
cache.cacheDirectory = path.resolve(testAppDir, '..', '.webpack-cache'); | ||
}); | ||
|
||
return webpackConfig; | ||
} | ||
|
||
describe('Functional persistent cache tests using webpack', function() { | ||
// being functional tests, these can take quite long | ||
this.timeout(10000); | ||
|
||
before(() => { | ||
// Only clear the temp folder when explicitly requested | ||
if (process.env.CLEAR_PERSISTENT_CACHE) { | ||
testSetup.emptyTmpDir(); | ||
} | ||
}); | ||
|
||
describe('Basic scenarios.', () => { | ||
it('Persistent caching does not cause problems', (done) => { | ||
const config = createWebpackConfig('www/build', 'basic_cache', 'dev'); | ||
config.setPublicPath('/build'); | ||
config.addEntry('main', './js/code_splitting'); | ||
|
||
testSetup.runWebpack(config, (webpackAssert) => { | ||
// sanity check | ||
webpackAssert.assertManifestPath( | ||
'build/main.js', | ||
'/build/main.js', | ||
); | ||
|
||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('copyFiles() allows to copy files and folders', () => { | ||
it('Persistent caching does not cause problems', (done) => { | ||
const config = createWebpackConfig('www/build', 'copy_files_cache', 'production'); | ||
config.addEntry('main', './js/no_require'); | ||
config.setPublicPath('/build'); | ||
config.enableVersioning(true); | ||
config.copyFiles([{ | ||
from: './images', | ||
includeSubdirectories: false, | ||
}]); | ||
|
||
testSetup.runWebpack(config, (webpackAssert) => { | ||
webpackAssert.assertDirectoryContents([ | ||
'entrypoints.json', | ||
'runtime.[hash:8].js', | ||
'main.[hash:8].js', | ||
'manifest.json', | ||
'symfony_logo.[hash:8].png', | ||
'symfony_logo_alt.[hash:8].png', | ||
]); | ||
|
||
webpackAssert.assertManifestPath( | ||
'build/symfony_logo.png', | ||
'/build/symfony_logo.91beba37.png', | ||
); | ||
|
||
webpackAssert.assertManifestPath( | ||
'build/symfony_logo_alt.png', | ||
'/build/symfony_logo_alt.f880ba14.png', | ||
); | ||
|
||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.