diff --git a/src/options.json b/src/options.json index 82f092b2..3430c7d8 100644 --- a/src/options.json +++ b/src/options.json @@ -2,7 +2,8 @@ "type": "object", "properties": { "implementation": { - "description": "The implementation of the sass to be used (https://github.com/webpack-contrib/sass-loader#implementation)." + "description": "The implementation of the sass to be used (https://github.com/webpack-contrib/sass-loader#implementation).", + "type": "object" }, "sassOptions": { "description": "Options for `node-sass` or `sass` (`Dart Sass`) implementation. (https://github.com/webpack-contrib/sass-loader#implementation).", diff --git a/test/__snapshots__/validate-options.test.js.snap b/test/__snapshots__/validate-options.test.js.snap index 2269113b..b78e0bed 100644 --- a/test/__snapshots__/validate-options.test.js.snap +++ b/test/__snapshots__/validate-options.test.js.snap @@ -1,6 +1,13 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`validate options 1`] = ` +"Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema. + - options.implementation should be an object: + object { … } + -> The implementation of the sass to be used (https://github.com/webpack-contrib/sass-loader#implementation)." +`; + +exports[`validate options 2`] = ` "Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema. - options.sassOptions should be one of these: object { … } | function @@ -11,7 +18,7 @@ exports[`validate options 1`] = ` * options.sassOptions should be an instance of function." `; -exports[`validate options 2`] = ` +exports[`validate options 3`] = ` "Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema. - options.prependData should be one of these: string | function @@ -21,13 +28,13 @@ exports[`validate options 2`] = ` * options.prependData should be an instance of function." `; -exports[`validate options 3`] = ` +exports[`validate options 4`] = ` "Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema. - options.webpackImporter should be a boolean. -> Enables/Disables default \`webpack\` importer (https://github.com/webpack-contrib/sass-loader#webpackimporter)." `; -exports[`validate options 4`] = ` +exports[`validate options 5`] = ` "Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema. - options has an unknown property 'unknown'. These properties are valid: object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter? }" diff --git a/test/validate-options.test.js b/test/validate-options.test.js index 7973982d..d1fb3e2e 100644 --- a/test/validate-options.test.js +++ b/test/validate-options.test.js @@ -20,11 +20,17 @@ it('validate options', () => { 'a { color: red; }' ); - // eslint-disable-next-line global-require - // expect(() => validate({ implementation: require('node-sass') })).not.toThrow(); - // eslint-disable-next-line global-require - // expect(() => validate({ implementation: require('sass') })).not.toThrow(); - // expect(() => validate({ implementation: true })).not.toThrow(); + expect(() => + // eslint-disable-next-line global-require + validate({ implementation: require('node-sass') }) + ).not.toThrow(); + expect(() => + // eslint-disable-next-line global-require + validate({ implementation: require('sass') }) + ).not.toThrow(); + expect(() => + validate({ implementation: true }) + ).toThrowErrorMatchingSnapshot(); expect(() => validate({ sassOptions: {} })).not.toThrow(); expect(() =>