diff --git a/test/__snapshots__/loader.test.js.snap b/test/__snapshots__/loader.test.js.snap index 5fb1b5e5..194b1211 100644 --- a/test/__snapshots__/loader.test.js.snap +++ b/test/__snapshots__/loader.test.js.snap @@ -1140,6 +1140,60 @@ exports[`loader should throw an error on ambiguous import (only on "dart-sass") exports[`loader should throw an error on ambiguous import (only on "dart-sass") (node-sass) (scss): warnings 1`] = `Array []`; +exports[`loader should throw an error on circular import (dart-sass) (sass): errors 1`] = ` +Array [ + "ModuleBuildError: Module build failed (from ../src/cjs.js): +SassError: This file is already being loaded.", +] +`; + +exports[`loader should throw an error on circular import (dart-sass) (sass): warnings 1`] = `Array []`; + +exports[`loader should throw an error on circular import (dart-sass) (scss): errors 1`] = ` +Array [ + "ModuleBuildError: Module build failed (from ../src/cjs.js): +SassError: This file is already being loaded.", +] +`; + +exports[`loader should throw an error on circular import (dart-sass) (scss): warnings 1`] = `Array []`; + +exports[`loader should throw an error on circular import (node-sass) (sass): errors 1`] = ` +Array [ + "ModuleBuildError: Module build failed (from ../src/cjs.js): +SassError: An @import loop has been found:", +] +`; + +exports[`loader should throw an error on circular import (node-sass) (sass): warnings 1`] = `Array []`; + +exports[`loader should throw an error on circular import (node-sass) (scss): errors 1`] = ` +Array [ + "ModuleBuildError: Module build failed (from ../src/cjs.js): +SassError: An @import loop has been found:", +] +`; + +exports[`loader should throw an error on circular import (node-sass) (scss): warnings 1`] = `Array []`; + +exports[`loader should throw an error on circular use (dart-sass) (sass): errors 1`] = ` +Array [ + "ModuleBuildError: Module build failed (from ../src/cjs.js): +SassError: Module loop: this module is already being loaded.", +] +`; + +exports[`loader should throw an error on circular use (dart-sass) (sass): warnings 1`] = `Array []`; + +exports[`loader should throw an error on circular use (dart-sass) (scss): errors 1`] = ` +Array [ + "ModuleBuildError: Module build failed (from ../src/cjs.js): +SassError: This file is already being loaded.", +] +`; + +exports[`loader should throw an error on circular use (dart-sass) (scss): warnings 1`] = `Array []`; + exports[`loader should throw an error with a explicit file and a file does not exist (dart-sass) (sass): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): diff --git a/test/loader.test.js b/test/loader.test.js index cb10b2c8..000115b2 100644 --- a/test/loader.test.js +++ b/test/loader.test.js @@ -997,6 +997,18 @@ describe("loader", () => { expect(getErrors(stats)).toMatchSnapshot("errors"); }); + it(`should throw an error on circular import (${implementationName}) (${syntax})`, async () => { + const testId = getTestId("import-circular", syntax); + const options = { + implementation: getImplementationByName(implementationName), + }; + const compiler = getCompiler(testId, { loader: { options } }); + const stats = await compile(compiler); + + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); + }); + if (implementation === dartSass) { it(`should output an understandable error with a problem in "@use" (${implementationName}) (${syntax})`, async () => { const testId = getTestId("error-use", syntax); @@ -1509,6 +1521,18 @@ describe("loader", () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); }); + + it(`should throw an error on circular use (${implementationName}) (${syntax})`, async () => { + const testId = getTestId("use-circular", syntax); + const options = { + implementation: getImplementationByName(implementationName), + }; + const compiler = getCompiler(testId, { loader: { options } }); + const stats = await compile(compiler); + + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); + }); } }); }); diff --git a/test/sass/import-circular.sass b/test/sass/import-circular.sass new file mode 100644 index 00000000..03684d3a --- /dev/null +++ b/test/sass/import-circular.sass @@ -0,0 +1 @@ +@import 'import-circular' \ No newline at end of file diff --git a/test/sass/use-circular.sass b/test/sass/use-circular.sass new file mode 100644 index 00000000..2adacedf --- /dev/null +++ b/test/sass/use-circular.sass @@ -0,0 +1 @@ +@use 'use-circular' \ No newline at end of file diff --git a/test/scss/import-circular.scss b/test/scss/import-circular.scss new file mode 100644 index 00000000..93a11409 --- /dev/null +++ b/test/scss/import-circular.scss @@ -0,0 +1 @@ +@import 'import-circular'; \ No newline at end of file diff --git a/test/scss/use-circular.scss b/test/scss/use-circular.scss new file mode 100644 index 00000000..94f76527 --- /dev/null +++ b/test/scss/use-circular.scss @@ -0,0 +1 @@ +@import 'use-circular'; \ No newline at end of file