Skip to content
This repository has been archived by the owner on Dec 6, 2021. It is now read-only.

Problem while loading test #35

Closed
plchampigny opened this issue Jul 4, 2019 · 5 comments
Closed

Problem while loading test #35

plchampigny opened this issue Jul 4, 2019 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@plchampigny
Copy link

Describe the bug
No tests are loaded. I had to show vscode debugger (CTRL+Shift+I) to find out the source of the issue

To Reproduce
I cannot upload a project to reproduce the issue. Hopefully the trace will indicate you the source

Logs
ERR The "path" argument must be of type string. Received type undefined: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
at assertPath (path.js:39:11)
at Object.join (path.js:432:7)
at SpecResponseToTestSuiteInfoMapper.createTest (C:\Users\Cactus.vscode\extensions\raagh.angular-karma-test-explorer-1.0.1\out\core\test-explorer\spec-response-to-test-suite-info.mapper.js:67:24)
at SpecResponseToTestSuiteInfoMapper.map (C:\Users\Cactus.vscode\extensions\raagh.angular-karma-test-explorer-1.0.1\out\core\test-explorer\spec-response-to-test-suite-info.mapper.js:18:18)
at KarmaEventListener.getLoadedTests (C:\Users\Cactus.vscode\extensions\raagh.angular-karma-test-explorer-1.0.1\out\core\integration\karma-event-listener.js:54:38)
at KarmaRunner. (C:\Users\Cactus.vscode\extensions\raagh.angular-karma-test-explorer-1.0.1\out\core\karma\karma-runner.js:19:44)
at Generator.next ()
at fulfilled (C:\Users\Cactus.vscode\extensions\raagh.angular-karma-test-explorer-1.0.1\node_modules\tslib\tslib.js:104:62)

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):
Angular CLI: 8.0.3
Node: 12.6.0
OS: win32 x64
Angular: 8.0.1
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, material, material-moment-adapter
... platform-browser, platform-browser-dynamic, router
... service-worker

Package Version

@angular-devkit/architect 0.800.3
@angular-devkit/build-angular 0.800.3
@angular-devkit/build-optimizer 0.800.3
@angular-devkit/build-webpack 0.800.3
@angular-devkit/core 8.0.3
@angular-devkit/schematics 8.0.3
@angular/cli 8.0.3
@angular/flex-layout 7.0.0-beta.23
@ngtools/webpack 8.0.3
@schematics/angular 7.3.4
@schematics/update 0.800.3
rxjs 6.5.2
typescript 3.4.5
webpack 4.30.0

Additional context
Problem seems to be related to missing information in the createTest and createSuite method, I tried to patch it by doing:
if (this.projectRootPath == null || specComplete.filePath == null) return;

but it still explodes from elsewhere. Don't know if its related to my karma/jasmine version
I also tried upgrading node from 10.16.0 to 12.6.0 and it is still exploding.
Having more logs or feedback would be usefull, the plugin seems to be loading even if it has failed.

@plchampigny plchampigny added the bug Something isn't working label Jul 4, 2019
@Raagh
Copy link
Owner

Raagh commented Jul 4, 2019

Hi pierre, thank you for submitting the bug. I will take a look at it tonight when I get home and create a test to reproduce it. That stacktrace seems to be enough to fix it. Could you do one try just to be sure, if you try it on a freshly created angular cli project does it work?

@Raagh
Copy link
Owner

Raagh commented Jul 4, 2019

@plchampigny I just pushed the fix for your problem. In a few minutes the new version should be built and published by the pipeline.

The problem is that if that's the case then some of your tests don't have a filePath(its undefined) then for those tests the show source function will not work.

I have tried it with my work project, and with a freshly created angular cli project and it works on both. could you provide me with an example test that doesn't have a filePath? could you show me your test structure so I can replicate the problem?

@plchampigny
Copy link
Author

@Raagh I'm testing the new extension, I've was about to post an error but it seems my vscode didnt reload the extension. I'll be investigating on my side which test doesnt have the goto file feature and check the reason why they dont.

@plchampigny
Copy link
Author

@Raagh Okay I found out the issue. We created internally a decorator system to create jasmine test using classes. For example:

@TestSuite('MyTestSuite')
export class MyTestSuite {
  @BeforeEach()
  public beforeEach() {
  }
 
  @Test()
  public async someTest() {
  }
}

will generate a suite with the name MyTestSuite and the someTest test

Looking at your code, I think you match the files content to find the test matching those files. Having a way to configure the regex to match these decorator for me would be wonderful.

@Raagh
Copy link
Owner

Raagh commented Jul 5, 2019

@plchampigny I understand the system, but I don't understand why tests are not being matched.

If you create the jasmine tests using those classes the "angular-karma_test-explorer/src/core/shared/path-finder.ts" should still found those jasmine tests that were created and use those. It will not map to the classes for sure but why is not mapping to those created jasmine tests? can you give me an example test class that is created? is your structure not matching the pattern used for getting the paths in this line ?

I am afraid that just having a property for the regex will not be enough if you re planning to match spec names to the classes instead of the test files, as PathFinder is also expecting to find keywords like "describe" and "it" it would need a complete new implementation. Maybe I can make a plugin implementation so that you can submit your own PathFinder implementation to the explorer and use that one instead. I need to do more investigation on this subject.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants