cypress-io / schema-tools

Validate, sanitize and document JSON schemas

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting cannot find module `../schemas` error when tried to trigger the Api spec test script in cypress.

soujanyarv opened this issue · comments

Please explain exactly what you did and provide the full error.

We have recently started using cypress for our E2E automation testing. We are trying to set up Json schema testing for API responses.

I have followed your blog for set up.
https://www.cypress.io/blog/2018/07/10/json-schemas-are-your-true-testing-friend/

Got stuck with the error Cannot find module '../../../../schemas' from '/Users/...

i have tried installing below

''npm install --save-dev webpack typescript ts-loader''

and added below code in cypress.plugins.js

const webpack = require('@cypress/webpack-preprocessor');

module.exports = plugins;

module.exports = on => {
const options = {
// send in the options from your webpack.config.js, so it works the same
// as your app's code
webpackOptions: require('../ui-cypress-e2e-local/webpack.config'),
watchOptions: {}
};

on('file:preprocessor', webpack(options));
};

With above changes, got below error after triggering my api script.
Error: Webpack Compilation Error
./node_modules/@cypress/schema-tools/src/fill.ts 12:9
Module parse failed: Unexpected token (12:9)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| // TODO: add types to input args
| export const fillBySchema = curry(

(schema: ObjectSchema, object: PlainObject): PlainObject => {
| // @ts-ignore

Later tried with ajv library for same set up and it is working good for now. Closing the ticket as issue solved.

Thanks for prompt response.