From 674cf44c493905343d46dec614626a8e87dc66b4 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com> Date: Mon, 1 Nov 2021 10:26:31 +0100 Subject: [PATCH] Add test --- .../core/integration-tests/test/resolver.js | 54 ++++++++++++------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/packages/core/integration-tests/test/resolver.js b/packages/core/integration-tests/test/resolver.js index a9cce188d35..d99b93c9c41 100644 --- a/packages/core/integration-tests/test/resolver.js +++ b/packages/core/integration-tests/test/resolver.js @@ -2,8 +2,8 @@ import assert from 'assert'; import path from 'path'; import {bundle, run, ncp, overlayFS, outputFS} from '@parcel/test-utils'; -describe('resolver', function() { - it('should support resolving tilde in monorepo packages', async function() { +describe('resolver', function () { + it('should support resolving tilde in monorepo packages', async function () { let b = await bundle( path.join( __dirname, @@ -15,7 +15,7 @@ describe('resolver', function() { assert.strictEqual(output.default, 1234); }); - it('should support node: prefix for node_modules', async function() { + it('should support node: prefix for node_modules', async function () { let b = await bundle( path.join(__dirname, '/integration/resolve-node-prefix/src/index.js'), ); @@ -27,7 +27,7 @@ describe('resolver', function() { ); }); - it('should correctly resolve tilde in node_modules', async function() { + it('should correctly resolve tilde in node_modules', async function () { let b = await bundle( path.join(__dirname, '/integration/resolve-tilde-nodemodules/index.js'), ); @@ -36,7 +36,7 @@ describe('resolver', function() { assert.strictEqual(output.default, 1234); }); - it('should fall back to index.js if the resolved `main` file does not exist', async function() { + it('should fall back to index.js if the resolved `main` file does not exist', async function () { let b = await bundle( path.join( __dirname, @@ -48,7 +48,7 @@ describe('resolver', function() { assert.strictEqual(output.default, 42); }); - it('should fall back to index.js if there is no `main` field at all', async function() { + it('should fall back to index.js if there is no `main` field at all', async function () { let b = await bundle( path.join(__dirname, '/integration/resolve-index-fallback/no-entry.js'), ); @@ -57,7 +57,7 @@ describe('resolver', function() { assert.strictEqual(output.default, 42); }); - it('should print a diagnostic when a configured target field will overwrite an entry', async function() { + it('should print a diagnostic when a configured target field will overwrite an entry', async function () { let errorThrows = 0; const overwriteDirs = ['browser', 'app', 'main', 'module']; for (const currDir of overwriteDirs) { @@ -89,7 +89,7 @@ describe('resolver', function() { assert.deepEqual(errorThrows, overwriteDirs.length); }); - it('should throw an error on Webpack loader imports', async function() { + it('should throw an error on Webpack loader imports', async function () { let didThrow = false; try { await bundle( @@ -109,7 +109,7 @@ describe('resolver', function() { assert(didThrow); }); - it('should throw an error with codeframe on invalid js import', async function() { + it('should throw an error with codeframe on invalid js import', async function () { let didThrow = false; try { await bundle( @@ -133,7 +133,7 @@ describe('resolver', function() { assert(didThrow); }); - it('should throw an error with codeframe on invalid css import', async function() { + it('should throw an error with codeframe on invalid css import', async function () { let didThrow = false; try { await bundle( @@ -157,7 +157,7 @@ describe('resolver', function() { assert(didThrow); }); - it('Should return codeframe with hints when package.json is invalid', async function() { + it('Should return codeframe with hints when package.json is invalid', async function () { let didThrow = false; try { await bundle( @@ -187,7 +187,7 @@ describe('resolver', function() { assert(didThrow); }); - it('Should suggest alternative filenames for relative imports', async function() { + it('Should suggest alternative filenames for relative imports', async function () { let threw = 0; try { @@ -244,7 +244,7 @@ describe('resolver', function() { assert.equal(threw, 3); }); - it('Should suggest alternative modules for module imports', async function() { + it('Should suggest alternative modules for module imports', async function () { let threw = false; try { @@ -268,7 +268,7 @@ describe('resolver', function() { assert(threw); }); - it('should resolve packages to packages through the alias field', async function() { + it('should resolve packages to packages through the alias field', async function () { let b = await bundle( path.join(__dirname, '/integration/alias/package-to-package.js'), ); @@ -277,7 +277,7 @@ describe('resolver', function() { assert.strictEqual(output.default, 3); }); - it('should resolve packages to local files through the alias field', async function() { + it('should resolve packages to local files through the alias field', async function () { let b = await bundle( path.join(__dirname, '/integration/alias/package-to-local.js'), ); @@ -286,7 +286,7 @@ describe('resolver', function() { assert.strictEqual(output.default, 'bar'); }); - it('should exclude local files using the alias field', async function() { + it('should exclude local files using the alias field', async function () { let b = await bundle( path.join(__dirname, '/integration/alias/exclude-local.js'), ); @@ -295,7 +295,7 @@ describe('resolver', function() { assert.deepEqual(output.default, {}); }); - it('should exclude packages using the alias field', async function() { + it('should exclude packages using the alias field', async function () { let b = await bundle( path.join(__dirname, '/integration/alias/exclude-package.js'), ); @@ -304,7 +304,7 @@ describe('resolver', function() { assert.deepEqual(output.default, {}); }); - it('should support symlinked node_modules structure', async function() { + it('should support symlinked node_modules structure', async function () { const rootDir = path.join( __dirname, 'integration/resolve-symlinked-node_modules-structure', @@ -346,7 +346,7 @@ describe('resolver', function() { assert.strictEqual(output.default, 42); }); - it('should support symlinked monorepos structure', async function() { + it('should support symlinked monorepos structure', async function () { const rootDir = path.join( __dirname, 'integration/resolve-symlinked-monorepos', @@ -382,4 +382,20 @@ describe('resolver', function() { let output = await run(b); assert.strictEqual(output.default, 2); }); + + it('should support very long dependency specifiers', async function () { + this.timeout(8000); + + let inputDir = path.join(__dirname, 'input'); + + await outputFS.mkdirp(inputDir); + await outputFS.writeFile( + path.join(inputDir, 'index.html'), + ``, + ); + + await bundle(path.join(inputDir, 'index.html'), { + inputFS: overlayFS, + }); + }); });