From ac14fd5a5069e3430a8c08f6958c5d401375f6e4 Mon Sep 17 00:00:00 2001 From: Evilebot Tnawi Date: Fri, 23 Aug 2019 22:55:46 +0300 Subject: [PATCH] test: fix `fiber` test (#747) --- .../sassOptions-option.test.js.snap | 24 +++++++++---------- test/sassOptions-option.test.js | 10 ++++++-- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/test/__snapshots__/sassOptions-option.test.js.snap b/test/__snapshots__/sassOptions-option.test.js.snap index 19b5e4dd..384f5d6c 100644 --- a/test/__snapshots__/sassOptions-option.test.js.snap +++ b/test/__snapshots__/sassOptions-option.test.js.snap @@ -752,7 +752,7 @@ exports[`sassOptions option should work when the option like "Object" (node-sass exports[`sassOptions option should work when the option like "Object" (node-sass) (scss): warnings 1`] = `Array []`; -exports[`sassOptions option should work with the "fibers" option (dart-sass) (sass): css 1`] = ` +exports[`sassOptions option should work with the "fiber" option (dart-sass) (sass): css 1`] = ` "@charset \\"UTF-8\\"; body { font: 100% Helvetica, sans-serif; @@ -807,11 +807,11 @@ nav a { }" `; -exports[`sassOptions option should work with the "fibers" option (dart-sass) (sass): errors 1`] = `Array []`; +exports[`sassOptions option should work with the "fiber" option (dart-sass) (sass): errors 1`] = `Array []`; -exports[`sassOptions option should work with the "fibers" option (dart-sass) (sass): warnings 1`] = `Array []`; +exports[`sassOptions option should work with the "fiber" option (dart-sass) (sass): warnings 1`] = `Array []`; -exports[`sassOptions option should work with the "fibers" option (dart-sass) (scss): css 1`] = ` +exports[`sassOptions option should work with the "fiber" option (dart-sass) (scss): css 1`] = ` "@charset \\"UTF-8\\"; body { font: 100% Helvetica, sans-serif; @@ -848,11 +848,11 @@ nav a { }" `; -exports[`sassOptions option should work with the "fibers" option (dart-sass) (scss): errors 1`] = `Array []`; +exports[`sassOptions option should work with the "fiber" option (dart-sass) (scss): errors 1`] = `Array []`; -exports[`sassOptions option should work with the "fibers" option (dart-sass) (scss): warnings 1`] = `Array []`; +exports[`sassOptions option should work with the "fiber" option (dart-sass) (scss): warnings 1`] = `Array []`; -exports[`sassOptions option should work with the "fibers" option (node-sass) (sass): css 1`] = ` +exports[`sassOptions option should work with the "fiber" option (node-sass) (sass): css 1`] = ` "@charset \\"UTF-8\\"; body { font: 100% Helvetica, sans-serif; @@ -899,11 +899,11 @@ nav a { " `; -exports[`sassOptions option should work with the "fibers" option (node-sass) (sass): errors 1`] = `Array []`; +exports[`sassOptions option should work with the "fiber" option (node-sass) (sass): errors 1`] = `Array []`; -exports[`sassOptions option should work with the "fibers" option (node-sass) (sass): warnings 1`] = `Array []`; +exports[`sassOptions option should work with the "fiber" option (node-sass) (sass): warnings 1`] = `Array []`; -exports[`sassOptions option should work with the "fibers" option (node-sass) (scss): css 1`] = ` +exports[`sassOptions option should work with the "fiber" option (node-sass) (scss): css 1`] = ` "@charset \\"UTF-8\\"; body { font: 100% Helvetica, sans-serif; @@ -936,9 +936,9 @@ nav a { " `; -exports[`sassOptions option should work with the "fibers" option (node-sass) (scss): errors 1`] = `Array []`; +exports[`sassOptions option should work with the "fiber" option (node-sass) (scss): errors 1`] = `Array []`; -exports[`sassOptions option should work with the "fibers" option (node-sass) (scss): warnings 1`] = `Array []`; +exports[`sassOptions option should work with the "fiber" option (node-sass) (scss): warnings 1`] = `Array []`; exports[`sassOptions option should work with the "functions" option (dart-sass) (sass): css 1`] = ` "h2, h3, h4, h5 { diff --git a/test/sassOptions-option.test.js b/test/sassOptions-option.test.js index 0191ba97..874e5a58 100644 --- a/test/sassOptions-option.test.js +++ b/test/sassOptions-option.test.js @@ -3,6 +3,7 @@ import path from 'path'; import semver from 'semver'; import nodeSass from 'node-sass'; import dartSass from 'sass'; +import Fiber from 'fibers'; import { compile, @@ -18,6 +19,11 @@ const implementations = [nodeSass, dartSass]; const syntaxStyles = ['scss', 'sass']; describe('sassOptions option', () => { + beforeEach(() => { + // The `sass` (`Dart Sass`) package modify the `Function` prototype, but the `jest` lose a prototype + Object.setPrototypeOf(Fiber, Function.prototype); + }); + implementations.forEach((implementation) => { const [implementationName] = implementation.info.split('\t'); @@ -154,7 +160,7 @@ describe('sassOptions option', () => { expect(stats.compilation.errors).toMatchSnapshot('errors'); }); - it(`should work with the "fibers" option (${implementationName}) (${syntax})`, async () => { + it(`should work with the "fiber" option (${implementationName}) (${syntax})`, async () => { const testId = getTestId('language', syntax); const options = { implementation: getImplementationByName(implementationName), @@ -163,7 +169,7 @@ describe('sassOptions option', () => { if (semver.satisfies(process.version, '>= 10')) { // eslint-disable-next-line global-require - options.sassOptions.fibers = require('fibers'); + options.sassOptions.fiber = Fiber; } const stats = await compile(testId, { loader: { options } });