|
| 1 | +/* |
| 2 | + * This file is part of the Symfony Webpack Encore 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 expect = require('chai').expect; |
| 13 | +const transform = require('../../../lib/friendly-errors/transformers/missing-css-file'); |
| 14 | + |
| 15 | +describe('transform/missing-css-file', () => { |
| 16 | + |
| 17 | + describe('test transform', () => { |
| 18 | + it('Error not with "ModuleNotFoundError" name is ignored', () => { |
| 19 | + const startError = { |
| 20 | + name: 'OtherParseError', |
| 21 | + message: 'You may need an appropriate loader', |
| 22 | + file: '/path/to/file.sass' |
| 23 | + }; |
| 24 | + const actualError = transform(Object.assign({}, startError)); |
| 25 | + |
| 26 | + expect(actualError).to.deep.equal(startError); |
| 27 | + }); |
| 28 | + |
| 29 | + it('Error not containing "Module not found: Error: Can\'t resolve" is ignored', () => { |
| 30 | + const startError = { |
| 31 | + name: 'ModuleNotFoundError', |
| 32 | + message: 'Some other message', |
| 33 | + file: '/path/to/file.sass' |
| 34 | + }; |
| 35 | + const actualError = transform(Object.assign({}, startError)); |
| 36 | + |
| 37 | + expect(actualError).to.deep.equal(startError); |
| 38 | + }); |
| 39 | + |
| 40 | + it('Matching error is properly transformed', () => { |
| 41 | + const startError = { |
| 42 | + name: 'ModuleNotFoundError', |
| 43 | + message: 'Module build failed: ModuleNotFoundError: Module not found: Error: Can\'t resolve \'./../images/symfony_logo.png2\' in \'/Users/weaverryan/Sites/os/webpack-encore/tmp_project_playing/css\'', |
| 44 | + file: '/Users/weaverryan/Sites/os/webpack-encore/tmp_project_playing/css' |
| 45 | + }; |
| 46 | + const actualError = transform(Object.assign({}, startError)); |
| 47 | + |
| 48 | + expect(actualError.ref).to.deep.equal('./../images/symfony_logo.png2'); |
| 49 | + expect(actualError.type).to.deep.equal('missing-css-file'); |
| 50 | + expect(actualError.file).to.deep.equal('/Users/weaverryan/Sites/os/webpack-encore/tmp_project_playing/css'); |
| 51 | + }); |
| 52 | + }); |
| 53 | +}); |
0 commit comments