mbolotov / intellij-cypress

IntelliJ-Cypress plugin: https://plugins.jetbrains.com/plugin/13819-intellij-cypress Pro version: https://plugins.jetbrains.com/plugin/13987-cypress-support-pro
MIT License
35 stars 5 forks source link

"No tests found" in Cypress example app #104

Closed karlkovaciny closed 1 year ago

karlkovaciny commented 1 year ago

Steps to reproduce:

I tried moving the tests to a cypress/integrations folder, but it didn't help.

mbolotov commented 1 year ago

Hi @karlkovaciny! Do you see such a message when opening this project, right? image

So the problem looks like the plugin is unable to evaluate the cypress configuration file to get the needed information. And because of this, it cannot find the tests and show the run icons.

I will dig into the problem in a few days.

karlkovaciny commented 1 year ago

Thanks for responding so fast. I don't see that error message as a popup, but I do see this in the PyCharm log and maybe that's the same thing (can't tell because the screenshot cuts off).

2022-09-09 10:31:55,565 [33167766]   INFO - #m.m.c.m.CyConfigService - Configuration output: 
2022-09-09 10:31:55,565 [33167766]   WARN - #m.m.c.m.CyConfigService - Configuration evaluation error output: 'node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module '/Users/********/Library/Caches/Cypress/10.7.0/Cypress/resources/app/packages/data-context/src/DataContext.js'
Require stack:
- /Users/*********/repos/cypress-realworld-app/[eval]
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at [eval]:1:19
    at Script.runInThisContext (node:vm:129:12)
    at Object.runInThisContext (node:vm:305:38)
    at node:internal/process/execution:76:19
    at [eval]-wrapper:6:22
    at evalScript (node:internal/process/execution:75:60) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/Users/********/repos/cypress-realworld-app/[eval]' ]
}
'

Another error I notice a little farther up in the PyCharm log is

2022-09-09 10:31:47,644 [33159845]   INFO - #c.i.u.i.UnindexedFilesUpdater - Started indexing of cypress-realworld-app. Reason: On project open
2022-09-09 10:31:47,644 [33159845]   INFO - #c.i.u.i.UnindexedFilesUpdater - Performing delayed pushing properties tasks for cypress-realworld-app took 0ms; general responsiveness: ok; EDT responsiveness: ok
2022-09-09 10:31:47,648 [33159849]   INFO - #c.i.u.i.UnindexedFilesUpdater - Scanning of cypress-realworld-app uses 11 scanning threads
2022-09-09 10:31:47,672 [33159873]   INFO - STDERR - java.lang.Throwable: Invocation timed out (1sec)
2022-09-09 10:31:47,672 [33159873]   INFO - STDERR -    at java.desktop/sun.lwawt.macosx.LWCToolkit.invokeAndWait(LWCToolkit.java:818)
2022-09-09 10:31:47,673 [33159874]   INFO - STDERR -    at java.desktop/sun.lwawt.macosx.LWCToolkit.invokeAndWait(LWCToolkit.java:664)
2022-09-09 10:31:47,673 [33159874]   INFO - STDERR -    at java.desktop/sun.lwawt.macosx.CAccessibility.invokeAndWait(CAccessibility.java:114)
2022-09-09 10:31:47,673 [33159874]   INFO - STDERR -    at java.desktop/sun.lwawt.macosx.CAccessibility.invokeAndWait(CAccessibility.java:108)
2022-09-09 10:31:47,673 [33159874]   INFO - STDERR -    at java.desktop/sun.lwawt.macosx.CAccessibility.getFocusOwner(CAccessibility.java:568)
2022-09-09 10:31:47,673 [33159874]   INFO - STDERR -    at java.desktop/sun.lwawt.macosx.LWCToolkit.doAWTRunLoopImpl(Native Method)
2022-09-09 10:31:47,673 [33159874]   INFO - STDERR -    at java.desktop/sun.lwawt.macosx.LWCToolkit.doAWTRunLoop(LWCToolkit.java:1049)
2022-09-09 10:31:47,673 [33159874]   INFO - STDERR -    at java.desktop/sun.lwawt.macosx.LWCToolkit.invokeAndWait(LWCToolkit.java:817)
2022-09-09 10:31:47,673 [33159874]   INFO - STDERR -    at java.desktop/sun.lwawt.macosx.LWCToolkit.invokeAndWait(LWCToolkit.java:664)
2022-09-09 10:31:47,674 [33159875]   INFO - STDERR -    at java.desktop/sun.lwawt.macosx.CAccessibility.invokeAndWait(CAccessibility.java:114)
2022-09-09 10:31:47,674 [33159875]   INFO - STDERR -    at java.desktop/sun.lwawt.macosx.CAccessibility.invokeAndWait(CAccessibility.java:108)
2022-09-09 10:31:47,674 [33159875]   INFO - STDERR -    at java.desktop/sun.lwawt.macosx.CAccessibility.getFocusOwner(CAccessibility.java:568)
2022-09-09 10:31:47,757 [33159958]   INFO - STDERR - java.lang.Throwable: Invocation timed out (1sec)
2022-09-09 10:31:47,757 [33159958]   INFO - STDERR -    at java.desktop/sun.lwawt.macosx.LWCToolkit.invokeAndWait(LWCToolkit.java:818)
2022-09-09 10:31:47,757 [33159958]   INFO - STDERR -    at java.desktop/sun.lwawt.macosx.LWCToolkit.invokeAndWait(LWCToolkit.java:664)
2022-09-09 10:31:47,757 [33159958]   INFO - STDERR -    at java.desktop/sun.lwawt.macosx.CAccessibility.invokeAndWait(CAccessibility.java:114)
2022-09-09 10:31:47,758 [33159959]   INFO - STDERR -    at java.desktop/sun.lwawt.macosx.CAccessibility.invokeAndWait(CAccessibility.java:108)
2022-09-09 10:31:47,758 [33159959]   INFO - STDERR -    at java.desktop/sun.lwawt.macosx.CAccessibility.getFocusOwner(CAccessibility.java:568)

Hope that helps!

mbolotov commented 1 year ago

It seems this project has to be built before being used with Cypress. I ran yarn dev and after that the plugin started to work successfully. Can you try this?

karlkovaciny commented 1 year ago

I did miss running yarn dev. I still don't see a Cypress run config in the gutter though.

I tried making one by hand (only filling in the project directory and test file) and that said

DevTools listening on ws://127.0.0.1:56978/devtools/browser/43f0e984-b200-40ae-97fb-cbbc32896ad4
Can't run because no spec files were found.

We searched for specs matching this glob pattern:

  > /Users/********/repos/cypress-realworld-app/src/components/AlertBar.cy.tsx

That is the path to a real file.

mbolotov commented 1 year ago

can you run successfully any cypress test in this project from the command line?

karlkovaciny commented 1 year ago

It took me a while because the API doesn't always launch on port 3001, but yes. I was able to run api-comments.spec.ts with yarn dev and npx cypress open --env CYPRESS_BASE_URL=http://localhost:3000 --e2e --browser=chrome, but immediately after that I still didn't see a Cypress option in my gutter for that file. This was true for the arrows next to both describe and it.

mbolotov commented 1 year ago

could you please collect the log data?

you need to enable the FINE log level: image image

#me.mbolotov.cypress:all

After that, please reopen a project with problem, collect the log and send it to me.

Please clear all the sensitive data if you have it in the Cypress configuration files.

karlkovaciny commented 1 year ago

I can give it to you if you want, but looking at the error again in that log, I think we can narrow it down to a Mac problem. The error message was "cannot find module" at this path:

/Users/*******/Library/Caches/Cypress/10.7.0/Cypress/resources/app/packages/data-context/src/DataContext.js

On my MacOS Monterey (not M1), with npx installed Cypress, that file is actually at

/Users/*******/Library/Caches/Cypress/10.7.0/Cypress.app/Contents/Resources/app/packages/data-context/src/DataContext.js

Do you have any advice on this or should I look into it more myself? Thanks for supporting your tool as much as you have.

mbolotov commented 1 year ago

Yes, you are right, this is a Mac problem. The plugin does not use the correct path in this case. Can you try this bundle with the fix? Cypress Support Pro-3.3.1-EAP.zip

karlkovaciny commented 1 year ago

I installed that bundle by uninstalling the plugin, then clicking the gear in plugins and picking "Install plugin from disk". It seems like it did something, because there are a few new things in the gutter: image

However,

I have emailed you the PyCharm debug log from opening the project after installing the bundle.

mbolotov commented 1 year ago
  1. Record option does not start a debug session (and never did). So the plugin does not stop on breakpoints under this option. Do you think this feature can be valuable?
  2. Please check what the spec pattern you have set in the Cypress config. The plugin only shows icons for specifications that can be run by Cypress according to the configuration. The icon you see for TransactionContainer.cy.tsx probably come from some other test framework (mocha or jest).
mbolotov commented 1 year ago

Hi @karlkovaciny I'm planning to release a new version of the plugin with the fix for this issue. Could you confirm that all works as expected?

karlkovaciny commented 1 year ago

@mbolotov Wow, I composed an entire comment 5 days ago that does not appear here. Thanks for following up. I did email you the debug log five days ago. No, it wasn't working right.

I only mentioned "Record" because I did not see any other new commands and wasn't sure that was part of the plugin.

(Edited) I have the e2e pattern "cypress/tests/**/*.spec.{js,jsx,ts,tsx}" and I guess the default specPattern for component, so:

Here is another log from opening the project. It is somehow a lot shorter than the one I mailed you before, probably because it isn't regenerating skeletons.

2022-09-21 10:34:06,155 [3676745]   INFO - #c.i.c.ComponentStoreImpl - Saving appEditorSettings took 11 ms, FeatureSuggesterSettings took 13 ms, FileTypeManager took 17 ms
2022-09-21 10:38:22,063 [3932653]   INFO - #c.i.c.ComponentStoreImpl - Saving Project(name=cypress-realworld-app, containerState=COMPONENT_CREATED, componentStore=/Users/********/repos/cypress-realworld-app)ProjectViewState took 15 ms, RunManager took 14 ms, VcsDirectoryMappings took 23 ms
2022-09-21 10:38:22,592 [3933182]   INFO - #c.j.r.f.FollowMeManager - Unregister user 0:'********' with ClientId=ClientId(value=Host)
2022-09-21 10:38:23,796 [3934386]   INFO - #c.i.c.ComponentStoreImpl - Saving appCodeFoldingSettings took 16 ms, CodeInsightSettings took 15 ms, CodeStyleSchemeSettings took 16 ms, DaemonCodeAnalyzerSettings took 16 ms, DiffSettings took 16 ms, DockerSettings took 16 ms, DontShowAgainFeedbackService took 105 ms
2022-09-21 10:38:26,483 [3937073]   INFO - #c.i.c.ComponentStoreImpl - Saving Project(name=Relish, containerState=COMPONENT_CREATED, componentStore=/Users/********/Relish)PublishConfigData took 16 ms, PyPackaging took 14 ms, PythonCompatibilityInspectionAdvertiser took 12 ms, SqlDialectMappings took 12 ms
2022-09-21 10:38:36,291 [3946881]   INFO - #c.j.r.p.c.t.i.DistributedTestHost - Host address=localhost/127.0.0.1
2022-09-21 10:38:36,322 [3946912]   INFO - #c.i.o.v.i.p.NewMappings - VCS Root: [Git] - [/Users/********/repos/cypress-realworld-app]
2022-09-21 10:38:36,322 [3946912]   INFO - #c.i.p.c.ProjectCodeStyleSettingsManager - Initialized from default code style settings.
2022-09-21 10:38:36,330 [3946920]   INFO - #c.i.o.w.StatusBar - Factory is not registered as `com.intellij.statusBarWidgetFactory` extension: com.intellij.openapi.vcs.changes.committed.IncomingChangesIndicatorFactory
2022-09-21 10:38:36,371 [3946961]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Load workspace model from cache in 78 ms
2022-09-21 10:38:36,390 [3946980]   INFO - #c.j.r.p.c.j.s - sessionStatus: null
2022-09-21 10:38:36,391 [3946981]   INFO - #c.j.r.p.c.j.s - freeSessionRemainingTimeMs: null null
2022-09-21 10:38:36,408 [3946998]   INFO - #c.i.i.n.e.NewToolbarRootPaneExtension - Show old main toolbar: false; show old navigation bar: true
2022-09-21 10:38:36,409 [3946999]   INFO - #c.i.i.n.e.NewToolbarRootPaneExtension - Show new main toolbar: false
2022-09-21 10:38:36,409 [3946999]   INFO - #c.i.o.w.StatusBar - Factory is not registered as `com.intellij.statusBarWidgetFactory` extension: git4idea.ui.branch.GitBranchWidget$Factory
2022-09-21 10:38:36,684 [3947274]   INFO - PerformancePlugin - Performance Plugin is in silent mode
2022-09-21 10:38:36,695 [3947285]   INFO - #c.i.o.e.s.p.m.ExternalProjectsDataStorage - Load external projects data in 0 millis (read time: 0)
2022-09-21 10:38:36,713 [3947303]   INFO - #c.i.i.s.p.i.BundledSharedIndexPostStartupActivity - Attached 2 pre-built shared indexes: bundled-python-sdk-47e0960b85fc-7f0ff5dbc1c8-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-221.5921.27, bundled-js-predefined-ffdd448c697d-b2f682bc4951-JavaScript-PY-221.5921.27
2022-09-21 10:38:36,825 [3947415]   INFO - #c.j.r.f.FollowMeManager - Register new user 0:'********' with ClientId=ClientId(value=Host)
2022-09-21 10:38:36,871 [3947461]   INFO - #c.i.d.PerformanceWatcherImpl - Post-startup activities under progress took 185ms; general responsiveness: ok; EDT responsiveness: ok
2022-09-21 10:38:36,973 [3947563]   INFO - #c.i.d.PerformanceWatcherImpl - Pushing JS language level of cypress-realworld-app to 536 libraries took 88ms; general responsiveness: ok; EDT responsiveness: ok
2022-09-21 10:38:37,146 [3947736]   INFO - #c.i.c.StatusBarInfoManager - === StatusBar.start create ===
2022-09-21 10:38:37,344 [3947934]   INFO - #c.i.u.i.UnindexedFilesUpdater - Started indexing of cypress-realworld-app. Reason: On project open
2022-09-21 10:38:37,345 [3947935]   INFO - #c.i.u.i.UnindexedFilesUpdater - Performing delayed pushing properties tasks for cypress-realworld-app took 0ms; general responsiveness: ok; EDT responsiveness: ok
2022-09-21 10:38:37,362 [3947952]   INFO - #c.i.u.i.UnindexedFilesUpdater - Scanning of cypress-realworld-app uses 11 scanning threads
2022-09-21 10:38:37,393 [3947983]   INFO - #c.i.o.f.i.FileEditorManagerImpl - Project opening took 1121 ms
2022-09-21 10:38:37,794 [3948384]   WARN - #c.i.o.a.i.ActionUpdater - 521 ms to grab EDT for #update (com.intellij.toolWindow.ToolWindowHeader$1)
2022-09-21 10:38:37,794 [3948384]   WARN - #c.i.o.a.i.ActionUpdater - 519 ms to grab EDT for #update (com.intellij.codeInsight.actions.ReaderModeActionProvider$createAction$1)
2022-09-21 10:38:38,367 [3948957]   INFO - #c.i.u.i.UnindexedFilesUpdater - Scanning completed for cypress-realworld-app. Number of scanned files: 22905; Number of files for indexing: 0 took 1022ms; general responsiveness: ok; EDT responsiveness: ok
2022-09-21 10:38:38,386 [3948976]   INFO - #c.i.u.i.UnindexedFilesUpdater - Finished for cypress-realworld-app. No files to index with loading content.
2022-09-21 10:38:38,392 [3948982]   INFO - c.i.s.v.a.s.d.SpaceKtsFileDetector - SpaceKtsFileDetector
2022-09-21 10:38:38,510 [3949100]   INFO - #c.i.o.a.i.PopupMenuPreloader - 2125 ms since showing to preload popup menu 'Edit' at 'MainMenu' in 108 ms
2022-09-21 10:38:38,514 [3949104]   INFO - #c.i.o.a.i.PopupMenuPreloader - 2129 ms since showing to preload popup menu 'File' at 'MainMenu' in 112 ms
2022-09-21 10:38:38,518 [3949108]   INFO - #c.i.o.a.i.PopupMenuPreloader - 2132 ms since showing to preload popup menu 'View' at 'MainMenu' in 116 ms
2022-09-21 10:38:38,519 [3949109]   INFO - #c.i.o.a.i.PopupMenuPreloader - 2133 ms since showing to preload popup menu 'Navigate' at 'MainMenu' in 116 ms
2022-09-21 10:38:38,521 [3949111]   INFO - #c.i.o.a.i.PopupMenuPreloader - 2136 ms since showing to preload popup menu 'Code' at 'MainMenu' in 119 ms
2022-09-21 10:38:38,522 [3949112]   INFO - #c.i.o.a.i.PopupMenuPreloader - 2137 ms since showing to preload popup menu 'Refactor' at 'MainMenu' in 120 ms
2022-09-21 10:38:38,541 [3949131]   INFO - #c.i.o.a.i.PopupMenuPreloader - 2155 ms since showing to preload popup menu 'Run' at 'MainMenu' in 138 ms
2022-09-21 10:38:38,543 [3949133]   INFO - #c.i.o.a.i.PopupMenuPreloader - 2157 ms since showing to preload popup menu 'Window' at 'MainMenu' in 140 ms
2022-09-21 10:38:38,544 [3949134]   INFO - #c.i.o.a.i.PopupMenuPreloader - 2158 ms since showing to preload popup menu 'Tools' at 'MainMenu' in 141 ms
2022-09-21 10:38:38,547 [3949137]   INFO - #c.i.o.a.i.PopupMenuPreloader - 2162 ms since showing to preload popup menu 'Help' at 'MainMenu' in 144 msÏ
karlkovaciny commented 1 year ago

I'm sorry, I was looking at the specPatterns from a different project. I edited the post above. The RWA project has

  e2e: {
    specPattern: "cypress/tests/**/*.spec.{js,jsx,ts,tsx}",

so cypress/tests/api/api-comments.spec.ts does match that.

mbolotov commented 1 year ago

Do you get the icons in cypress/tests/api/api-comments.spec.ts now? the new log does not show any plugin related activities - that's strange.

karlkovaciny commented 1 year ago

Yes, I still have the "record" and "cy" icons I did in my previous screenshot.

The log above was just from doing "file > Recent > open". I just sent your gmail another copy of the log, starting from a closed PyCharm. At least it mentions the plugin when I do that.

mbolotov commented 1 year ago

so all works as expected from your point of view, right?

karlkovaciny commented 1 year ago

I had some misconceptions:

I can confirm that using the "debug" play arrow launches Cypress instead of Jest, and hits breakpoints in my Cypress tests. You can close this issue and release your new version.

mbolotov commented 1 year ago

I will look into possibility to debug the app code, thanks. The original problem is fixed in 3.3.1 version

karlkovaciny commented 1 year ago

Thank you for the fast and helpful support!