Invalid chai property jsonschema - mocha.js

I'm working on the API automation using mocha and chai.
I need to compare the response of the api and compare it with chai jsonschema assertion.
expect(response).to.be.jsonSchema(expectedResponse)
I get the following error,
Error: Invalid Chai property: jsonSchema
at Object.proxyGetter [as get] (node_modules\chai\lib\chai\utils\proxify.js:78:17)
at _callee2$ (test\/ServerEndPointsTest.js:70:21)
at tryCatch (node_modules\regenerator-runtime\runtime.js:63:40)
at Generator.invoke [as _invoke] (node_modules\regenerator-runtime\runtime.js:294:22)
at Generator.next (node_modules\regenerator-runtime\runtime.js:119:21)
at asyncGeneratorStep (node_modules\#babel\runtime\helpers\asyncToGenerator.js:3:24)
at _next (node_modules\#babel\runtime\helpers\asyncToGenerator.js:25:9)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

You have not mentioned the imports of your test file and most likely that is the place where you are making a mistake.
These sorts of errors are thrown by the chai library when you try to use something which is not in-built in your case the chai-json-schema plugin.
Try to update your imports as below:
const {expect} = require("chai").use(require('chai-json-schema'));
This will add the required methods of the chai plugin to your expect object.

Related

nexus generate supabase url not found (env variable)

Prisma Nexus generate does not find environment variable
I have import 'dotenv/config' at the root of my Apollo Server set. So I can develop fine. However, when I try to run ts-node --transpile-only apollo/schema I get the following error.
This tells me that dotenv isn't running on generate. Is there a configuration for this somewhere?
/{user-path}/node_modules/#supabase/supabase-js/src/SupabaseClient.ts:62
if (!supabaseUrl) throw new Error('supabaseUrl is required.')
^
Error: supabaseUrl is required.
at new SupabaseClient (/{user-path}/node_modules/#supabase/supabase-js/src/SupabaseClient.ts:62:29)
at createClient (/{user-path}/node_modules/#supabase/supabase-js/src/index.ts:21:10)
at /{user-path}/apollo/src/supabase-client.ts:9:22
at Object.<anonymous> (/{user-path}/apollo/src/supabase-client.ts:10:3)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Module.m._compile (/{user-path}/node_modules/ts-node/src/index.ts:1371:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Object.require.extensions.<computed> [as .ts] (/{user-path}/node_modules/ts-node/src/index.ts:1374:12)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
error Command failed with exit code 1.
I put import 'dotenv/config' at the root of the apollo server so running the server was fine. However, when I go to build the schema directly I don't get my env vars. So I also put the dotenv/config in my schema.ts. It's not a great solution since on server startup I config twice. But it works for now. Would appreciate to hear a better solution if anyone has one.

The following error originated from your test code, not from Cypress - process is not defined

I am getting this error when try to run the test in Cypress. Can someone help me how to resolve this, please?
This is my index.js
// Import commands.js using ES2015 syntax:
import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')
Cypress.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false
})
The line where it errors
const env = process.env
is only valid in NodeJS, where process is a global object supplied by the Node runtime.
Cypress has both a Node process to which you can add plugins via the file cypress/plugins/index.js and a Browser process where you can add code to cypress/support/index.js.
The error comes from a package called ci-info, so it looks like you have imported it or something that uses it into cypress/support/index.js or cypress/support/commands.js, or directly into a test.
Please check all your imports.
I had to remove import "cypress" from my test. That fixed it. 9.7.0
This happened for me when I imported cypress within my test, removing that fixed the issue
This was the issue in my case , I removed it from my test's file. Now, Its working
const cypress = require("cypress");

mocha-webpack ignores my webpack.config.js?

I am using the npm 5.2.0 with mocha-webpack to run my tests. However, my webpack.config.js seem to be ignored as I get all kind of errors of Aliases not being used in my webpack.config.js file.
My package.json command:
"test:mocha": "mocha-webpack",
My mocha-webpack.opts:
--webpack-config webpack.config.js
--colors
--require ignore-styles
--require babel-core/register
--require jsdom-global/register
**/tests/*.test.js
My mocha-webpack.opts is being used as the error output is in red.
I also tried with a
--webpack-config webpack.config-test.js
That contains only the required webpack stuff: babel en aliases, but the same errors appear.
Some of the errors:
Module not found: Error: Can't resolve 'Redux/actions' in '/CodeRepo/checklist/src/js'
resolve 'Redux/actions' in '/CodeRepo/checklist/src/js'
Parsed request is a module
Module parse failed: /CodeRepo/buttons/iconTextButton.js Unexpected token (16:12)
You may need an appropriate loader to handle this file type.
Any idea how to solve this? (I followed the example on the net, and the npm mocha-webpack page, but couldn't get it solved).

Vue-strap with Laravel: Module build failed

I'm not sure if Vue-strap works with 2.0 so I want to try using its Navbar component.
I add this in app.js.
Vue.component('navbar', require('../../../node_modules/vue-strap/src/Navbar.vue'));
gulp watch throws this error.
ERROR in ./~/vue-strap/src/utils/NodeList.js
Module build failed: Error
at ForOfStatement.initialise (/var/www/web_redeem/node_modules/buble/dist/buble.umd.js:2004:65)
at /var/www/web_redeem/node_modules/buble/dist/buble.umd.js:9381:56
at Array.forEach (native)
at BlockStatement.initialise (/var/www/web_redeem/node_modules/buble/dist/buble.umd.js:9381:15)
at FunctionDeclaration.initialise (/var/www/web_redeem/node_modules/buble/dist/buble.umd.js:858:12)
at FunctionDeclaration.initialise (/var/www/web_redeem/node_modules/buble/dist/buble.umd.js:2071:31)
at /var/www/web_redeem/node_modules/buble/dist/buble.umd.js:9381:56
at Array.forEach (native)
at BlockStatement.initialise (/var/www/web_redeem/node_modules/buble/dist/buble.umd.js:9381:15)
# ./~/buble-loader!./~/vue-loader/lib/selector.js?type=script&index=0!./~/vue-strap/src/Navbar.vue 33:0-35
# ./~/vue-strap/src/Navbar.vue
# ./resources/assets/js/app.js
Elixir compiles js with Bublé that does not support for ... of statements yet. Consider switching to babel instead.
If you are you using https://github.com/vuejs/laravel-elixir-vue-2 change to https://github.com/JeffreyWay/laravel-elixir-vue

How to make karma work with a webpack, Angular2, and SASS project?

I am using angular2-webpack-starter and I have my stylesheets as SASS. Everything is working perfectly, but when I try to run karma tests it fails giving me this error
ERROR in ./src/app/widgets/message/messages.scss
Module parse failed: d:\ui_widgets-A2\src\app\widgets\message\messages.scss Unexpected token (6:22)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (6:22)
at Parser.pp.raise (d:\ui_widgets-A2\node_modules\acorn\dist\acorn.js:920:13)
at Parser.pp.unexpected (d:\ui_widgets-A2\node_modules\acorn\dist\acorn.js:1483:8)
at Parser.pp.semicolon (d:\ui_widgets-A2\node_modules\acorn\dist\acorn.js:1462:73)
at Parser.pp.parseExpressionStatement (d:\ui_widgets-A2\node_modules\acorn\dist\acorn.js:1976:8)
at Parser.pp.parseStatement (d:\ui_widgets-A2\node_modules\acorn\dist\acorn.js:1754:188)
at Parser.pp.parseTopLevel (d:\ui_widgets-A2\node_modules\acorn\dist\acorn.js:1648:21)
at Parser.parse (d:\ui_widgets-A2\node_modules\acorn\dist\acorn.js:1616:17)
at Object.parse (d:\ui_widgets-A2\node_modules\acorn\dist\acorn.js:882:44)
at Parser.parse (d:\ui_widgets-A2\node_modules\webpack\lib\Parser.js:902:15)
at DependenciesBlock.<anonymous> (d:\ui_widgets-A2\node_modules\webpack\lib\NormalModule.js:104:16)
at DependenciesBlock.onModuleBuild (d:\ui_widgets-A2\node_modules\webpack-core\lib\NormalModuleMixin.js:310:10)
at nextLoader (d:\ui_widgets-A2\node_modules\webpack-core\lib\NormalModuleMixin.js:275:25)
at d:\ui_widgets-A2\node_modules\webpack-core\lib\NormalModuleMixin.js:259:5
at Storage.finished (d:\ui_widgets-A2\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:38:16)
at d:\ui_widgets-A2\node_modules\graceful-fs\graceful-fs.js:78:16
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:439:3)
# ./src/app/widgets/message/message.component.ts 9:431-457
I tried to install karma-sass-preprocessor and karma-scss-preprocessor but nothing seems to work. What should I do?
So the answer is pretty trivial, I had
{
test: /\.scss$/,
exclude: /node_modules/,
loaders: ['raw-loader', 'sass-loader']
}
in my webpack.common.js and for some reason I thought that webpack.test.js was getting it as well, but as it turns out I should have also added it to webpack.test.js
I would suggest you using angular cli there you have nice examples with bootstrapping project.
https://cli.angular.io/
https://github.com/angular/angular-cli#css-preprocessor-integration
But here you can find some answers regarding your problem:
https://github.com/AngularClass/angular2-webpack-starter/issues/136

Resources