Skip to content

Commit

Permalink
test: circular (#921)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Feb 5, 2021
1 parent f403a4e commit 90dc7f1
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 0 deletions.
54 changes: 54 additions & 0 deletions test/__snapshots__/loader.test.js.snap
Expand Up @@ -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):
Expand Down
24 changes: 24 additions & 0 deletions test/loader.test.js
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
});
}
});
});
Expand Down
1 change: 1 addition & 0 deletions test/sass/import-circular.sass
@@ -0,0 +1 @@
@import 'import-circular'
1 change: 1 addition & 0 deletions test/sass/use-circular.sass
@@ -0,0 +1 @@
@use 'use-circular'
1 change: 1 addition & 0 deletions test/scss/import-circular.scss
@@ -0,0 +1 @@
@import 'import-circular';
1 change: 1 addition & 0 deletions test/scss/use-circular.scss
@@ -0,0 +1 @@
@import 'use-circular';

0 comments on commit 90dc7f1

Please sign in to comment.