|
| 1 | +import path from 'path'; |
| 2 | + |
| 3 | +import { createProcessDriver } from 'karton'; |
| 4 | + |
| 5 | +import { createWebpackDevServerDriver } from './driver/webpack-dev-server-driver'; |
| 6 | + |
| 7 | +describe('Webpack Inclusive Watcher', () => { |
| 8 | + it.each([{ async: false }, { async: true }])( |
| 9 | + 'ignores package.json change for %p', |
| 10 | + async ({ async }) => { |
| 11 | + await sandbox.load(path.join(__dirname, 'fixtures/typescript-basic')); |
| 12 | + await sandbox.load(path.join(__dirname, 'fixtures/typescript-package')); |
| 13 | + await sandbox.install('yarn', { typescript: '4.6.3' }); |
| 14 | + await sandbox.patch('webpack.config.js', 'async: false,', `async: ${JSON.stringify(async)},`); |
| 15 | + |
| 16 | + // add import to typescript-nested-project project |
| 17 | + await sandbox.patch( |
| 18 | + 'src/index.ts', |
| 19 | + "import { getUserName } from './model/User';", |
| 20 | + [ |
| 21 | + "import { getUserName } from './model/User';", |
| 22 | + 'import { sayHello } from "../package";', |
| 23 | + '', |
| 24 | + "sayHello('World');", |
| 25 | + ].join('\n') |
| 26 | + ); |
| 27 | + |
| 28 | + // start webpack dev server |
| 29 | + const process = sandbox.spawn('yarn webpack serve --mode=development'); |
| 30 | + const baseDriver = createProcessDriver(process); |
| 31 | + const webpackDriver = createWebpackDevServerDriver(process, async); |
| 32 | + |
| 33 | + await webpackDriver.waitForNoErrors(); |
| 34 | + |
| 35 | + // update nested package.json file |
| 36 | + await sandbox.patch('package/package.json', '"1.0.0"', '"1.0.1"'); |
| 37 | + |
| 38 | + // wait for 5 seconds and fail if there is Debug Failure. in the console output |
| 39 | + await expect(() => |
| 40 | + baseDriver.waitForStderrIncludes('Error: Debug Failure.', 5000) |
| 41 | + ).rejects.toEqual( |
| 42 | + new Error('Exceeded time on waiting for "Error: Debug Failure." to appear in the stderr.') |
| 43 | + ); |
| 44 | + |
| 45 | + await webpackDriver.waitForNoErrors(); |
| 46 | + } |
| 47 | + ); |
| 48 | +}); |
0 commit comments