diff --git a/src/utils.js b/src/utils.js index 4badab53..657db602 100644 --- a/src/utils.js +++ b/src/utils.js @@ -767,8 +767,8 @@ function getCompileFn(loaderContext, implementation, options) { // Check again because awaiting the initialization function // introduces a race condition. - if (!sassModernCompilers.has(implementation)) { - sassModernCompilers.set(implementation, compiler); + if (!sassModernCompilers.has(webpackCompiler)) { + sassModernCompilers.set(webpackCompiler, compiler); webpackCompiler.hooks.shutdown.tap("sass-loader", () => { compiler.dispose(); }); @@ -776,7 +776,7 @@ function getCompileFn(loaderContext, implementation, options) { } return sassModernCompilers - .get(implementation) + .get(webpackCompiler) .compileStringAsync(data, rest); } diff --git a/test/additionalData-option.test.js b/test/additionalData-option.test.js index 1ae63d6a..9e700b9b 100644 --- a/test/additionalData-option.test.js +++ b/test/additionalData-option.test.js @@ -1,5 +1,6 @@ import { compile, + close, getCodeFromBundle, getCodeFromSass, getCompiler, @@ -35,6 +36,8 @@ describe("additionalData option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work as a function ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -60,6 +63,8 @@ describe("additionalData option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work as an async function ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -85,6 +90,8 @@ describe("additionalData option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should use same EOL on all os ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -106,6 +113,8 @@ a { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); }); }); diff --git a/test/helpers/close.js b/test/helpers/close.js new file mode 100644 index 00000000..5ba5db15 --- /dev/null +++ b/test/helpers/close.js @@ -0,0 +1,10 @@ +export default (compiler) => + new Promise((resolve, reject) => { + compiler.close((error) => { + if (error) { + return reject(error); + } + + return resolve(); + }); + }); diff --git a/test/helpers/index.js b/test/helpers/index.js index 5ac8020f..44fe909f 100644 --- a/test/helpers/index.js +++ b/test/helpers/index.js @@ -1,4 +1,5 @@ import compile from "./compiler"; +import close from "./close"; import customFunctions from "./customFunctions"; import customImporter from "./customImporter"; import getCodeFromBundle from "./getCodeFromBundle"; @@ -13,6 +14,7 @@ import readAsset from "./readAsset"; export { compile, + close, customFunctions, customImporter, getCodeFromBundle, diff --git a/test/implementation-option.test.js b/test/implementation-option.test.js index 4c3734fb..1e8ecd14 100644 --- a/test/implementation-option.test.js +++ b/test/implementation-option.test.js @@ -4,6 +4,7 @@ import dartSass from "sass"; import * as sassEmbedded from "sass-embedded"; import { + close, compile, getCodeFromBundle, getCompiler, @@ -149,6 +150,8 @@ describe("implementation option", () => { sassEmbeddedSpy.mockClear(); sassEmbeddedSpyModernAPI.mockClear(); sassEmbeddedCompilerSpies.mockClear(); + + await close(compiler); }); }); @@ -162,6 +165,8 @@ describe("implementation option", () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it("not specify", async () => { @@ -182,6 +187,8 @@ describe("implementation option", () => { nodeSassSpy.mockClear(); dartSassSpy.mockClear(); + + await close(compiler); }); it("not specify with legacy API", async () => { @@ -204,6 +211,8 @@ describe("implementation option", () => { nodeSassSpy.mockClear(); dartSassSpy.mockClear(); + + await close(compiler); }); it("not specify with modern API", async () => { @@ -226,6 +235,8 @@ describe("implementation option", () => { nodeSassSpy.mockClear(); dartSassSpyModernAPI.mockClear(); + + await close(compiler); }); it("not specify with modern-compiler API", async () => { @@ -250,6 +261,8 @@ describe("implementation option", () => { nodeSassSpy.mockClear(); dartSassSpyModernAPI.mockClear(); dartSassCompilerSpies.mockClear(); + + await close(compiler); }); it.each(["dart-sass", "sass-embedded"])( @@ -279,6 +292,8 @@ describe("implementation option", () => { dartSassCompilerSpies.mockClear(); sassEmbeddedCompilerSpies.mockClear(); + + await close(compiler); }, ); @@ -295,6 +310,8 @@ describe("implementation option", () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it('should throw an error when the "info" is unparseable', async () => { @@ -308,6 +325,8 @@ describe("implementation option", () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it('should throw error when the "info" does not exist', async () => { @@ -322,6 +341,8 @@ describe("implementation option", () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it("should try to load using valid order", async () => { @@ -360,6 +381,8 @@ describe("implementation option", () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it("should not swallow an error when trying to load a sass implementation", async () => { @@ -389,5 +412,7 @@ describe("implementation option", () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); }); diff --git a/test/loader.test.js b/test/loader.test.js index aef277d1..7fd34463 100644 --- a/test/loader.test.js +++ b/test/loader.test.js @@ -5,6 +5,7 @@ import del from "del"; import { compile, + close, getCodeFromBundle, getCodeFromSass, getCompiler, @@ -33,6 +34,7 @@ describe("loader", () => { api, }; const compiler = getCompiler(testId, { loader: { options } }); + const stats = await compile(compiler); const codeFromBundle = getCodeFromBundle(stats, compiler); const codeFromSass = await getCodeFromSass(testId, options); @@ -41,6 +43,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work ('${implementationName}', '${api}' API, '${syntax}' syntax) and don't modify sass options`, async () => { @@ -72,6 +76,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work ('${implementationName}', '${api}' API, '${syntax}' syntax) with the "memory" cache`, async () => { @@ -101,6 +107,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work ('${implementationName}', '${api}' API, '${syntax}' syntax) with the "filesystem" cache`, async () => { @@ -131,6 +139,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with an empty file ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -148,6 +158,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should output an understandable error ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -166,6 +178,8 @@ describe("loader", () => { ).toBe(true); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should output an understandable error when the problem in "@import" ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -189,6 +203,8 @@ describe("loader", () => { ).toBe(true); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should output an understandable error when a file could not be found ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -207,6 +223,8 @@ describe("loader", () => { ).toBe(true); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should throw an error with a explicit file and a file does not exist ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -225,6 +243,8 @@ describe("loader", () => { ).toBe(true); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with difference "@import" at-rules ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -242,6 +262,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); // Test for issue: https://github.com/webpack-contrib/sass-loader/issues/32 @@ -260,6 +282,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); // Test for issue: https://github.com/webpack-contrib/sass-loader/issues/73 @@ -278,6 +302,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@import" at-rules from scoped npm packages ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -295,6 +321,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@import" at-rules with extensions ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -312,6 +340,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@import" at-rules starting with "_" ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -329,6 +359,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@import" at-rules without extensions and do not start with "_" ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -349,6 +381,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with multiple "@import" at-rules without quotes ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -370,6 +404,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work and use the "sass" field ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -387,6 +423,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work and use the "style" field ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -404,6 +442,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work and use the "main" field ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -421,6 +461,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work and use the "main" field when the "main" value is not in the "mainFields" resolve option ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -440,6 +482,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work and use the "main" field when the "main" value already in the "mainFields" resolve option ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -459,6 +503,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work and use the "custom-sass" field ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -481,6 +527,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work and use the "index" file in package ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -498,6 +546,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work and use the "index" file in package when the "index" value is not in the "mainFiles" resolve option ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -517,6 +567,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work and use the "index" file in package when the "index" value already in the "mainFiles" resolve option ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -536,6 +588,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should prefer "mainFiles" over "mainFields" when the field contains "js" file ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -556,6 +610,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should prefer "mainFiles" with extension over without ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -579,6 +635,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work and use the "_index" file in package ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -596,6 +654,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with an alias ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -643,6 +703,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); // Legacy support for CSS imports with node-sass @@ -662,6 +724,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); if (!isNodeSass) { @@ -680,6 +744,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); } @@ -699,6 +765,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); } @@ -717,6 +785,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with "bootstrap" package v4 without tilde, import as a package ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -733,6 +803,8 @@ describe("loader", () => { expect(codeFromBundle.css).toBe(codeFromSass.css); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with "bootstrap" package v5, import as a package ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -750,6 +822,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with "bootstrap" package v5 without tilde, import as a package ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -766,6 +840,8 @@ describe("loader", () => { expect(codeFromBundle.css).toBe(codeFromSass.css); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); if (!isNodeSass) { @@ -787,6 +863,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with the "foundation-sites" package, adjusting CSS output ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -810,6 +888,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); } @@ -838,6 +918,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should watch firstly in the "includePaths" values ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -870,6 +952,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should load only sass/scss files for the "mainFiles" ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -890,6 +974,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should load files with underscore in the name ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -907,6 +993,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should respect resolving from the "SASS_PATH" environment variable ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -938,6 +1026,8 @@ describe("loader", () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + await close(compiler); + delete process.env.SASS_PATH; }); @@ -958,6 +1048,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should respect resolving directory with the "index" file from "process.cwd()" ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -978,6 +1070,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); } @@ -996,6 +1090,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with a package with "sass" and "exports" fields and a custom condition (theme1) ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1023,6 +1119,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with a package with "sass" and "exports" fields and a custom condition (theme2) ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1050,6 +1148,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); if (!isModernAPI) { @@ -1081,6 +1181,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); } @@ -1099,6 +1201,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should resolve absolute paths ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1110,15 +1214,15 @@ describe("loader", () => { content .replace( /\/scss\/language.scss/g, - `file:///${path - .resolve(__dirname, "scss/language.scss") - .replace(/\\/g, "/")}`, + url.pathToFileURL( + path.resolve(__dirname, "scss/language.scss"), + ), ) .replace( /\/sass\/language.sass/g, - `file:///${path - .resolve(__dirname, "sass/language.sass") - .replace(/\\/g, "/")}`, + url.pathToFileURL( + path.resolve(__dirname, "sass/language.sass"), + ), ), }; const compiler = getCompiler(testId, { loader: { options } }); @@ -1130,6 +1234,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should throw an error on ambiguous import (only on "dart-sass") ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1143,6 +1249,8 @@ describe("loader", () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should prefer relative import ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1160,6 +1268,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with the 'resolve.byDependency.sass' option ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1186,6 +1296,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should throw an error on circular import ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1199,6 +1311,8 @@ describe("loader", () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work prefer \`loadPaths\` over \`SASS_PATH\` ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1237,6 +1351,8 @@ describe("loader", () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + await close(compiler); + delete process.env.SASS_PATH; }); @@ -1259,6 +1375,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work ('${implementationName}', '${api}' API, '${syntax}' syntax) add "@charset "UTF-8";" for non ascii characters`, async () => { @@ -1276,6 +1394,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work ('${implementationName}', '${api}' API, '${syntax}' syntax) to disable "@charset "UTF-8";" generation`, async () => { @@ -1294,6 +1414,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should output an understandable error with a problem in "@use" ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1317,6 +1439,8 @@ describe("loader", () => { ).toBe(true); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should output an understandable error when a file could not be found using "@use" rule ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1337,6 +1461,8 @@ describe("loader", () => { ).toBe(true); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should throw an error with a explicit file and a file does not exist using "@use" rule ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1357,6 +1483,8 @@ describe("loader", () => { ).toBe(true); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with different "@use" at-rules ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1374,6 +1502,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with "@use" at-rules from other language style ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1391,6 +1521,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" at-rules from scoped npm packages ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1408,6 +1540,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" at-rules with extensions ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1425,6 +1559,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" at-rules starting with "_" ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1442,6 +1578,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" at-rules without extensions and do not start with "_" ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1462,6 +1600,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" and use the "sass" field ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1479,6 +1619,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" and use the "style" field ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1496,6 +1638,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" and use the "main" field ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1513,6 +1657,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" and use the "main" field when the "main" value is not in the "mainFields" resolve option ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1532,6 +1678,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" and use the "main" field when the "main" value already in the "mainFields" resolve option ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1551,6 +1699,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" and use the "custom-sass" field ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1573,6 +1723,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" and use the "index" file in package ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1590,6 +1742,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" and use the "index" file in package when the "index" value is not in the "mainFiles" resolve option ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1609,6 +1763,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" and use the "index" file in package when the "index" value already in the "mainFiles" resolve option ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1628,6 +1784,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" and use the "_index" file in package ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1645,6 +1803,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" with an alias ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1694,6 +1854,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" with the "bootstrap-sass" package, directly import ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1711,6 +1873,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" with the "bootstrap-sass" package, import as a package ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1728,6 +1892,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" with "bootstrap" package v4, import as a package ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1745,6 +1911,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" with "bootstrap" package v4 without tilde, import as a package ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1762,6 +1930,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" with "bootstrap" package v5, import as a package ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1779,6 +1949,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when "@use" with "bootstrap" package v5 without tilde, import as a package ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1796,6 +1968,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats, true)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with "bootstrap" and custom imports ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1812,6 +1986,8 @@ describe("loader", () => { expect(codeFromBundle.css).toBe(codeFromSass.css); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with the "material-components-web" package ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1832,6 +2008,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with the "material-components-web" package without the "includePaths" option ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1849,6 +2027,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with the "material-components-web" package ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1869,6 +2049,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with the "material-components-web" package without the "includePaths" option ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1886,6 +2068,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should import .import.${syntax} files ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1903,6 +2087,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should import .import.${syntax} files from a package ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1920,6 +2106,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should not use .import.${syntax} files ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1933,6 +2121,8 @@ describe("loader", () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should prefer "${syntax})" over CSS ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1950,6 +2140,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work and output deprecation message (${implementationName})`, async () => { @@ -1967,6 +2159,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats, true)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should throw an error on circular use ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -1980,6 +2174,8 @@ describe("loader", () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should use webpack logger ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -2015,6 +2211,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); expect(logs).toMatchSnapshot("logs"); }); @@ -2044,6 +2242,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); expect(logs).toMatchSnapshot("logs"); }); @@ -2062,6 +2262,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with "pkg" prefix in "@use" ('${implementationName}', '${api}' API, '${syntax}' syntax) with "@charset "UTF-8";"`, async () => { @@ -2077,6 +2279,8 @@ describe("loader", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); } }); diff --git a/test/sassOptions-option.test.js b/test/sassOptions-option.test.js index cafbe813..b36933f2 100644 --- a/test/sassOptions-option.test.js +++ b/test/sassOptions-option.test.js @@ -13,6 +13,7 @@ import { getWarnings, getCompiler, getImplementationsAndAPI, + close, } from "./helpers"; jest.setTimeout(30000); @@ -44,6 +45,8 @@ describe("sassOptions option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when the option is empty "Object" ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -62,6 +65,8 @@ describe("sassOptions option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when the option like "Function" ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -88,6 +93,8 @@ describe("sassOptions option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work when the option like "Function" and never return ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -110,6 +117,8 @@ describe("sassOptions option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); if (isModernAPI) { @@ -133,6 +142,8 @@ describe("sassOptions option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with custom scheme import ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -166,6 +177,8 @@ describe("sassOptions option", () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); } else { it(`should ignore the "file" option ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -186,6 +199,8 @@ describe("sassOptions option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); } @@ -207,6 +222,8 @@ describe("sassOptions option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with the "functions" option ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -232,6 +249,8 @@ describe("sassOptions option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); if (!isModernAPI) { @@ -253,6 +272,8 @@ describe("sassOptions option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with the "importer" as a array of functions option ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -273,6 +294,8 @@ describe("sassOptions option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with the "importer" as a single function option ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -297,6 +320,8 @@ describe("sassOptions option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); } @@ -321,6 +346,8 @@ describe("sassOptions option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); } @@ -349,6 +376,8 @@ describe("sassOptions option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); if (api !== "modern" && api !== "modern-compiler") { @@ -368,6 +397,8 @@ describe("sassOptions option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); } @@ -388,6 +419,8 @@ describe("sassOptions option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with the "indentedSyntax"/"syntax" option ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -413,6 +446,8 @@ describe("sassOptions option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should work with the "linefeed" option ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -435,6 +470,8 @@ describe("sassOptions option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should respect the "outputStyle"/"style" option ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -459,6 +496,8 @@ describe("sassOptions option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should use "compressed" output style in the "production" mode ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -482,6 +521,8 @@ describe("sassOptions option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); }); }); diff --git a/test/sourceMap-options.test.js b/test/sourceMap-options.test.js index ea4444c8..e504203b 100644 --- a/test/sourceMap-options.test.js +++ b/test/sourceMap-options.test.js @@ -4,6 +4,7 @@ import url from "url"; import { compile, + close, getCodeFromBundle, getCompiler, getErrors, @@ -49,6 +50,8 @@ describe("sourceMap option", () => { expect(sourceMap).toMatchSnapshot("source map"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should generate source maps when value has "true" value and the "devtool" option has "source-map" value ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -80,6 +83,8 @@ describe("sourceMap option", () => { expect(sourceMap).toMatchSnapshot("source map"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should generate source maps when value has "true" value and the "devtool" option has "false" value ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -111,6 +116,8 @@ describe("sourceMap option", () => { expect(sourceMap).toMatchSnapshot("source map"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should generate source maps when value has "false" value, but the "sassOptions.sourceMap" has the "true" value ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -170,6 +177,8 @@ describe("sourceMap option", () => { expect(sourceMap).toMatchSnapshot("source map"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should not generate source maps when value is not specified and the "devtool" option has "false" value ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -186,6 +195,8 @@ describe("sourceMap option", () => { expect(sourceMap).toMatchSnapshot("source map"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should not generate source maps when value has "false" value and the "devtool" option has "source-map" value ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -202,6 +213,8 @@ describe("sourceMap option", () => { expect(sourceMap).toMatchSnapshot("source map"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`should not generate source maps when value has "false" value and the "devtool" option has "false" value ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -218,6 +231,8 @@ describe("sourceMap option", () => { expect(sourceMap).toMatchSnapshot("source map"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); }); }); diff --git a/test/warnRuleAsWarning.test.js b/test/warnRuleAsWarning.test.js index 6f758d12..0b7f0c40 100644 --- a/test/warnRuleAsWarning.test.js +++ b/test/warnRuleAsWarning.test.js @@ -1,6 +1,7 @@ import url from "url"; import { + close, compile, getCodeFromBundle, getCodeFromSass, @@ -55,6 +56,8 @@ describe("loader", () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); expect(logs).toMatchSnapshot("logs"); + + await close(compiler); }); it(`should not emit warning when 'false' used ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -92,6 +95,8 @@ describe("loader", () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); expect(logs).toMatchSnapshot("logs"); + + await close(compiler); }); it(`should emit warning when 'true' used ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -129,6 +134,8 @@ describe("loader", () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); expect(logs).toMatchSnapshot("logs"); + + await close(compiler); }); if (syntax === "sass" && implementationName !== "node-sass") { @@ -164,6 +171,8 @@ describe("loader", () => { expect(getWarnings(stats, true)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); expect(logs).toMatchSnapshot("logs"); + + await close(compiler); }); } }); diff --git a/test/webpackImporter-options.test.js b/test/webpackImporter-options.test.js index 94161844..b1aa0ede 100644 --- a/test/webpackImporter-options.test.js +++ b/test/webpackImporter-options.test.js @@ -1,4 +1,5 @@ import { + close, compile, getCodeFromBundle, getCodeFromSass, @@ -37,6 +38,8 @@ describe("webpackImporter option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`false ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -55,6 +58,8 @@ describe("webpackImporter option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); it(`true ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { @@ -73,6 +78,8 @@ describe("webpackImporter option", () => { expect(codeFromBundle.css).toMatchSnapshot("css"); expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); }); }); });