bahmutov / add-typescript-to-cypress

Quickly adds TypeScript spec support to Cypress
https://github.com/bahmutov/test-add-typescript-to-cypress
107 stars 6 forks source link

import json cause the Cypress to crash #104

Open zshlomyz opened 4 years ago

zshlomyz commented 4 years ago

Hi, I want to assert that the visual content match to the data from the server. For that i made a few things:

  1. Import a json file (import assetsMock from '../../fixtures/assets.json')
  2. Use it as the response of cy.route
  3. Asset that some DOM element contain the same data

I just added this package in order to write test using typescript. Now - the import statement cause Cypress to crash with this error:

Error running plugin

The following error was thrown by a plugin. We've stopped running your tests because a plugin crashed.

./cypress/integration/infrastructure/assets.ts Module build failed (from ./node_modules/ts-loader/index.js): Error: Debug Failure. File C:\cypress_typescript_test\cypress\fixtures\assets.json has unknown extension. at Object.extensionFromPath (C:\cypress_typescript_test\node_modules\typescript\lib\typescript.js:4694:15) at C:\cypress_typescript_test\node_modules\typescript\lib\typescript.js:78448:46 at Array.map () at resolveModuleNamesWorker (C:\cypress_typescript_test\node_modules\typescript\lib\typescript.js:78442:195) at resolveModuleNamesReusingOldState (C:\cypress_typescript_test\node_modules\typescript\lib\typescript.js:78703:19) at processImportedModules (C:\cypress_typescript_test\node_modules\typescript\lib\typescript.js:79804:35) at findSourceFile (C:\cypress_typescript_test\node_modules\typescript\lib\typescript.js:79696:17) at C:\cypress_typescript_test\node_modules\typescript\lib\typescript.js:79567:85 at getSourceFileFromReferenceWorker (C:\cypress_typescript_test\node_modules\typescript\lib\typescript.js:79534:34) at processSourceFile (C:\cypress_typescript_test\node_modules\typescript\lib\typescript.js:79567:13) at processRootFile (C:\cypress_typescript_test\node_modules\typescript\lib\typescript.js:79414:13) at C:\cypress_typescript_test\node_modules\typescript\lib\typescript.js:78497:60 at Object.forEach (C:\cypress_typescript_test\node_modules\typescript\lib\typescript.js:1792:30) at Object.createProgram (C:\cypress_typescript_test\node_modules\typescript\lib\typescript.js:78497:16) at synchronizeHostData (C:\cypress_typescript_test\node_modules\typescript\lib\typescript.js:107641:26) at Object.getProgram (C:\cypress_typescript_test\node_modules\typescript\lib\typescript.js:107723:13) at Object.ensureProgram (C:\cypress_typescript_test\node_modules\ts-loader\dist\utils.js:177:41) at Object.getEmitOutput (C:\cypress_typescript_test\node_modules\ts-loader\dist\instances.js:178:29) at getEmit (C:\cypress_typescript_test\node_modules\ts-loader\dist\index.js:242:37) at successLoader (C:\cypress_typescript_test\node_modules\ts-loader\dist\index.js:67:15) at Object.loader (C:\cypress_typescript_test\node_modules\ts-loader\dist\index.js:22:12) @ multi ./cypress/integration/infrastructure/assets.ts main[0]

Please help