wallabyjs / ngCliWebpackSample

68 stars 48 forks source link

Problem with ngrx/effects/testing + Wallaby #23

Closed philipooo closed 7 years ago

philipooo commented 7 years ago

Hi

I recently updates angular-cli and the wallaby config and came up with some errors while running wallaby. This was not the case before updating the wallaby config file.

I setup a repo to demonstrate the error:

1 failing tests, 3 passing

src/app/effects.spec.ts My Effects should work [9 ms]

TypeError: testing_2.provideMockActions is not a function
    at Object.<anonymous> src/app/effects.spec.ts:15

TypeError: Cannot read property 'test$' of undefined
    at Object.<anonymous> src/app/effects.spec.ts:25

See here: https://github.com/philipooo/ngCliWebpackSample/commit/974487dd25d3e357ab63b2713d29b2c45defa737

The error does not occure when using the wallaby config contained in https://github.com/philipooo/ngCliWebpackSample/blob/ngrx-error/wallaby.before.js

Any ideas why this is happening?

Cheers Philip

ArtemGovorov commented 7 years ago

Hi,

I have cloned your repo, switched to the ngrx-error branch, ran npm install and wallaby is working for me (with both configs).

screen shot 2017-09-11 at 10 03 29 pm

Perhaps it is wallaby caching issue, could you please try changing wallaby config (even a space anywhere will do, this should clear the cache) and restarting it?

If it doesn't help, please try:

Please let me know how it goes.

ArtemGovorov commented 7 years ago

Also (if cache clearing doesn't help), please attach your generated wallaby bundle file. You may get the file as follows:

philipooo commented 7 years ago

Hey @ArtemGovorov Thank you for your fast response. I tried to clear the cache, but got the same result. Also commenting out line 20 and/or 5 and restarting wallaby did not change the result.

It attached the bundle file. ____wallaby-bundle.zip

ArtemGovorov commented 7 years ago

Thanks! I'm still struggling to see what the issue is, could you please:

Also try commenting out this line to see if it changes anything: https://github.com/philipooo/ngCliWebpackSample/blob/974487dd25d3e357ab63b2713d29b2c45defa737/wallaby.js#L31.

ArtemGovorov commented 7 years ago

After reviewing the attached bundle file, I have found something that may be the reason for the issue.

According to the source code of bundle that you've attached, you are using @ngrx/effects v2.x. However the sample project that you've provided is using @ngrx/effects v4.x. It means that you probably have not re-installed node modules, and we are trying 2 different setups here.

Try cloning your sample project from the scratch, switching to the ngrx-error branch, running npm install and running wallaby. Or try clearing your node modules folder and deleting package-lock.json file and running npm install.

ArtemGovorov commented 7 years ago

Yep, I have just tried to run npm i @ngrx/effects@2, and I'm getting the same results as you are:

1 failing tests, 3 passing

src/app/effects.spec.ts My Effects should work [6 ms]

    TypeError: testing_2.provideMockActions is not a function
        at Object.<anonymous> src/app/effects.spec.ts:15

    TypeError: Cannot read property 'test$' of undefined
        at Object.<anonymous> src/app/effects.spec.ts:25

Also I'm getting the exact same results with both wallaby config - the new one and the old one. The issue here is that @ngrx/effects v2.x doesn't support the API you are trying to use.

philipooo commented 7 years ago

Thanks for your investigations. You are right. There is v2 in the bundle, and of course the API does not exist there. Thats really wierd because I have cloned your repo and directly installed the latest versions of ngrx/effects and ngrx/store. So there should be no v2. Cloning my repo again an running npm install does not help.

If I use the old config there is ngrx/effects@v4 in the bundle. If I use the new config there is ngrx/effects@v2 in the bundle.

I have to try this on the machine of a colleague.

ArtemGovorov commented 7 years ago

Cloning my repo again an running npm install does not help.

If I use the old config there is ngrx/effects@v4 in the bundle. If I use the new config there is ngrx/effects@v2 in the bundle.

Do you mean your real repo at work or your sample https://github.com/philipooo/ngCliWebpackSample/tree/ngrx-error? I can't see how it's possible that @ngrx/effect v2 is installed in your sample, there's the package-lock file and searching for @ngrx/effect in it only brings up v4 dependencies. When I search the node modules folder, I also can't find any v2 copies.

philipooo commented 7 years ago

Yes I mean the sample repo you also cloned. I tried it on the machine of a colleague now and it works like it works on your machine.

Must be a caching problem...I will continue investigating.

ArtemGovorov commented 7 years ago

Try searching for the @ngrx/effect v2 in the installed node_modules, starting from the project's folder and going up till the root drive, e.g. first in c:\a\b\c\ngCliWebpackSample\node_modules, then c:\a\b\c\node_modules, c:\a\b\node_modules, etc.

philipooo commented 7 years ago

There is only the node_modules of the project itself in the chain, containing v4. Now I checked %AppData%/npm-cache on my windows machine and deleted the @ngrx folder. No success.

ArtemGovorov commented 7 years ago

Try this: open the node_modules/wallaby-webpack/index.js file and add the following line as the line 372:

static _getModuleId(m, file, isEntryFile) {
+   if (m && m.rawRequest  === '@ngrx/effects/testing') console.log(m.resource, m._source);
    var testFile = file && file.test;
    ...

then start wallaby and paste the Wallaby Console output here.

philipooo commented 7 years ago
wallaby.js started
core v1.0.486
Tue, 12 Sep 2017 08:51:32 GMT wallaby:project Wallaby config: C:/Develop/ngCliWebpackSample-2/wallaby.js
Tue, 12 Sep 2017 08:51:32 GMT wallaby:project File cache: C:\Users\p.s\.WebStorm2017.2\system\wallaby\projects\17bba317ca2de014
Tue, 12 Sep 2017 08:51:32 GMT wallaby:uiService Listening port 51235
Tue, 12 Sep 2017 08:51:33 GMT wallaby:workers Parallelism for initial run: 6, for regular run: 3
Tue, 12 Sep 2017 08:51:33 GMT wallaby:workers Starting run worker instance #0
Tue, 12 Sep 2017 08:51:33 GMT wallaby:workers Starting run worker instance #1
Tue, 12 Sep 2017 08:51:33 GMT wallaby:workers Starting run worker instance #2
Tue, 12 Sep 2017 08:51:33 GMT wallaby:workers Starting run worker instance #3
Tue, 12 Sep 2017 08:51:33 GMT wallaby:workers Starting run worker instance #4
Tue, 12 Sep 2017 08:51:33 GMT wallaby:workers Starting run worker instance #5

Tue, 12 Sep 2017 08:51:33 GMT wallaby:workers Web server is listening at 50843
Tue, 12 Sep 2017 08:51:33 GMT wallaby:uiService UI client connected
Tue, 12 Sep 2017 08:51:33 GMT wallaby:uiService Outgoing message ui:handshake
Tue, 12 Sep 2017 08:51:33 GMT wallaby:uiService Incoming message ui:start
Tue, 12 Sep 2017 08:51:33 GMT wallaby:uiService Outgoing message ui:summary
Tue, 12 Sep 2017 08:51:33 GMT wallaby:uiService Outgoing message ui:files
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Stopping process pool
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project File cache is up-to-date, starting full test run
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Running postprocessor
Tue, 12 Sep 2017 08:51:33 GMT wallaby:postprocessor New TypeScript language service is required
Tue, 12 Sep 2017 08:51:33 GMT wallaby:postprocessor TypeScript compiler options module (before tsconfig.json): 1
Tue, 12 Sep 2017 08:51:33 GMT wallaby:postprocessor TypeScript compiler options module (after tsconfig.json): 1
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Preparing to process src/app/actions.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Preparing to process src/app/app.component.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Preparing to process src/app/app.module.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Preparing to process src/app/effects.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Preparing to process src/app/reducer.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Preparing to process src/environments/environment.prod.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Preparing to process src/environments/environment.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Preparing to process src/main.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Preparing to process src/polyfills.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Preparing to process src/test.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Preparing to process src/wallabyTest.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Preparing to process src/app/app.component.spec.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Preparing to process src/app/effects.spec.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Processing compiled src/app/actions.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Instrumenting src/app/actions.js, via process pool: false
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Processing compiled src/app/app.component.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Instrumenting src/app/app.component.js, via process pool: false
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Processing compiled src/app/app.module.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Instrumenting src/app/app.module.js, via process pool: false
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Processing compiled src/app/effects.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Instrumenting src/app/effects.js, via process pool: false
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Processing compiled src/app/reducer.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Instrumenting src/app/reducer.js, via process pool: false
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Processing compiled src/environments/environment.prod.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Instrumenting src/environments/environment.prod.js, via process pool: false
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Processing compiled src/environments/environment.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Instrumenting src/environments/environment.js, via process pool: false
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Processing compiled src/main.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Instrumenting src/main.js, via process pool: false
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Processing compiled src/polyfills.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Instrumenting src/polyfills.js, via process pool: false
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Processing compiled src/test.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Instrumenting src/test.js, via process pool: false
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Processing compiled src/wallabyTest.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Instrumenting src/wallabyTest.js, via process pool: false
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Processing compiled src/app/app.component.spec.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Instrumenting src/app/app.component.spec.js, via process pool: false
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Processing compiled src/app/effects.spec.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Instrumenting src/app/effects.spec.js, via process pool: false
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project No preprocessors configured for src/app/actions.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project No preprocessors configured for src/app/app.component.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project No preprocessors configured for src/app/app.module.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project No preprocessors configured for src/app/effects.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project No preprocessors configured for src/app/reducer.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project No preprocessors configured for src/environments/environment.prod.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project No preprocessors configured for src/environments/environment.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project No preprocessors configured for src/main.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project No preprocessors configured for src/polyfills.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project No preprocessors configured for src/test.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project No preprocessors configured for src/wallabyTest.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project No preprocessors configured for src/app/app.component.spec.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project No preprocessors configured for src/app/effects.spec.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Writing to disk and caching processed file src/app/actions.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Writing to disk and caching processed file src/app/app.component.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Writing to disk and caching processed file src/app/app.module.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Writing to disk and caching processed file src/app/effects.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Writing to disk and caching processed file src/app/reducer.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Writing to disk and caching processed file src/environments/environment.prod.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Writing to disk and caching processed file src/environments/environment.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Writing to disk and caching processed file src/main.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Writing to disk and caching processed file src/polyfills.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Writing to disk and caching processed file src/test.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Writing to disk and caching processed file src/wallabyTest.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Writing to disk and caching processed file src/app/app.component.spec.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:project Writing to disk and caching processed file src/app/effects.spec.js
Tue, 12 Sep 2017 08:51:33 GMT wallaby:workers Started run worker instance (immediate) #0
Tue, 12 Sep 2017 08:51:33 GMT wallaby:workers Started run worker instance (immediate) #1
Tue, 12 Sep 2017 08:51:33 GMT wallaby:workers Started run worker instance (immediate) #2
Tue, 12 Sep 2017 08:51:33 GMT wallaby:workers Started run worker instance (immediate) #3
Tue, 12 Sep 2017 08:51:33 GMT wallaby:workers Started run worker instance (immediate) #4
Tue, 12 Sep 2017 08:51:33 GMT wallaby:workers Started run worker instance (immediate) #5
Tue, 12 Sep 2017 08:51:33 GMT wallaby:postprocessor New compiler created
Tue, 12 Sep 2017 08:51:34 GMT wallaby:postprocessor Webpack compilation started
Tue, 12 Sep 2017 08:51:36 GMT wallaby:postprocessor Webpack compilation finished
C:\Users\p.steinebrunner\node_modules\@ngrx\effects\testing\index.js OriginalSource {
_value: 'export * from \'./runner\';\nexport * from \'./testing.module\';\n//# sourceMappingURL=index.js.map',
_name: 'C:\\Users\\p.steinebrunner\\node_modules\\@ngrx\\effects\\testing\\index.js' }
C:\Users\p.steinebrunner\node_modules\@ngrx\effects\testing\index.js OriginalSource {
_value: 'export * from \'./runner\';\nexport * from \'./testing.module\';\n//# sourceMappingURL=index.js.map',
_name: 'C:\\Users\\p.steinebrunner\\node_modules\\@ngrx\\effects\\testing\\index.js' }
Tue, 12 Sep 2017 08:51:36 GMT wallaby:postprocessor Emitting 196 files
Tue, 12 Sep 2017 08:51:36 GMT wallaby:project Postprocessor execution finished
Tue, 12 Sep 2017 08:51:36 GMT wallaby:project Test run started; run priority: 3
Tue, 12 Sep 2017 08:51:36 GMT wallaby:project Running all tests
Tue, 12 Sep 2017 08:51:36 GMT wallaby:workers Starting test run, priority: 3
Tue, 12 Sep 2017 08:51:36 GMT wallaby:workers Distributing tests between 6 workers
Tue, 12 Sep 2017 08:51:36 GMT wallaby:workers Running tests in parallel
Tue, 12 Sep 2017 08:51:36 GMT wallaby:electronRunner Starting sandbox [worker #0, session #w728w]
Tue, 12 Sep 2017 08:51:36 GMT wallaby:electronRunner Starting sandbox [worker #1, session #0n45e]
Tue, 12 Sep 2017 08:51:36 GMT wallaby:electronRunner Preparing sandbox [worker #0, session #w728w]
Tue, 12 Sep 2017 08:51:36 GMT wallaby:browserRunner Total files to load in sandbox: 4
Tue, 12 Sep 2017 08:51:36 GMT wallaby:browserRunner Sandbox is generated [worker #0, session #w728w]: http://localhost:50843/wallaby_sandbox0.html
Tue, 12 Sep 2017 08:51:36 GMT wallaby:electronRunner Preparing sandbox [worker #1, session #0n45e]
Tue, 12 Sep 2017 08:51:36 GMT wallaby:browserRunner Total files to load in sandbox: 4
Tue, 12 Sep 2017 08:51:36 GMT wallaby:browserRunner Sandbox is generated [worker #1, session #0n45e]: http://localhost:50843/wallaby_sandbox1.html
Tue, 12 Sep 2017 08:51:36 GMT wallaby:electronRunner Prepared sandbox [worker #0, session #w728w]
Tue, 12 Sep 2017 08:51:36 GMT wallaby:electronRunner Prepared sandbox [worker #1, session #0n45e]
Tue, 12 Sep 2017 08:51:36 GMT wallaby:workers Running tests in sandbox [worker #0, session #w728w]
Tue, 12 Sep 2017 08:51:36 GMT wallaby:workers Running tests in sandbox [worker #1, session #0n45e]
Tue, 12 Sep 2017 08:51:37 GMT wallaby:middleware Preparing to serve C:\Users\p.steinebrunner\.WebStorm2017.2\system\wallaby\wallaby\tracer.js
Tue, 12 Sep 2017 08:51:37 GMT wallaby:middleware Serving C:\Users\p.steinebrunner\.WebStorm2017.2\system\wallaby\wallaby\tracer.js from disk
Tue, 12 Sep 2017 08:51:37 GMT wallaby:middleware Preparing to serve /jasmine@2.6.3/framework.js
Tue, 12 Sep 2017 08:51:37 GMT wallaby:middleware Serving /jasmine@2.6.3/framework.js from disk
Tue, 12 Sep 2017 08:51:37 GMT wallaby:middleware Preparing to serve /jasmine@2.1.3/configurator.js
Tue, 12 Sep 2017 08:51:37 GMT wallaby:middleware Serving /jasmine@2.1.3/configurator.js from disk
Tue, 12 Sep 2017 08:51:37 GMT wallaby:middleware Preparing to serve /jasmine@2.1.3/reporter.js
Tue, 12 Sep 2017 08:51:37 GMT wallaby:middleware Serving /jasmine@2.1.3/reporter.js from disk
Tue, 12 Sep 2017 08:51:37 GMT wallaby:middleware Preparing to serve /wallaby-webpack.js
Tue, 12 Sep 2017 08:51:37 GMT wallaby:middleware Serving /wallaby-webpack.js from cache
Tue, 12 Sep 2017 08:51:37 GMT wallaby:middleware Preparing to serve /____wallaby-bundle.js
Tue, 12 Sep 2017 08:51:37 GMT wallaby:middleware Serving /____wallaby-bundle.js from cache
Tue, 12 Sep 2017 08:51:37 GMT wallaby:middleware Preparing to serve /wallaby_webpack_entry.js
Tue, 12 Sep 2017 08:51:37 GMT wallaby:middleware Serving /wallaby_webpack_entry.js from cache
Tue, 12 Sep 2017 08:51:37 GMT wallaby:middleware Preparing to serve /src/app/effects.spec.js.wbp.js
Tue, 12 Sep 2017 08:51:37 GMT wallaby:middleware Serving /src/app/effects.spec.js.wbp.js from cache
Tue, 12 Sep 2017 08:51:37 GMT wallaby:middleware Preparing to serve /jasmine@2.1.3/starter.js
Tue, 12 Sep 2017 08:51:37 GMT wallaby:middleware Serving /jasmine@2.1.3/starter.js from disk
Tue, 12 Sep 2017 08:51:37 GMT wallaby:middleware Preparing to serve /src/app/app.component.spec.js.wbp.js
Tue, 12 Sep 2017 08:51:37 GMT wallaby:middleware Serving /src/app/app.component.spec.js.wbp.js from cache
Tue, 12 Sep 2017 08:51:37 GMT wallaby:workers Loaded 1 test(s)
Tue, 12 Sep 2017 08:51:37 GMT wallaby:workers Loaded 3 test(s)
Tue, 12 Sep 2017 08:51:37 GMT wallaby:workers Test executed: should work
Tue, 12 Sep 2017 08:51:37 GMT wallaby:workers Run 1 test(s), skipped 0 test(s)
Tue, 12 Sep 2017 08:51:37 GMT wallaby:workers Sandbox [0n45e] is responsive, closing it
Tue, 12 Sep 2017 08:51:37 GMT wallaby:workers Test executed: should create the app
Tue, 12 Sep 2017 08:51:37 GMT wallaby:workers Test executed: should have as title 'app'
Tue, 12 Sep 2017 08:51:38 GMT wallaby:workers Test executed: should render title in a h1 tag
Tue, 12 Sep 2017 08:51:38 GMT wallaby:workers Run 3 test(s), skipped 0 test(s)
Tue, 12 Sep 2017 08:51:38 GMT wallaby:workers Sandbox [w728w] is responsive, closing it
Tue, 12 Sep 2017 08:51:38 GMT wallaby:workers Merging parallel test run results
Finished executing 4 affected test(s)
Tue, 12 Sep 2017 08:51:38 GMT wallaby:project Test run finished
Tue, 12 Sep 2017 08:51:38 GMT wallaby:project Processed console.log entries
Tue, 12 Sep 2017 08:51:38 GMT wallaby:project Processed loading sequences
Tue, 12 Sep 2017 08:51:38 GMT wallaby:project Processed executed tests
Tue, 12 Sep 2017 08:51:38 GMT wallaby:project Processed code coverage
Tue, 12 Sep 2017 08:51:38 GMT wallaby:project Test run result processed and sent to IDE
Tue, 12 Sep 2017 08:51:38 GMT wallaby:project Unable to load test run screen shot
Tue, 12 Sep 2017 08:51:38 GMT wallaby:uiService Outgoing message ui:summary
Tue, 12 Sep 2017 08:51:38 GMT wallaby:uiService Outgoing message ui:coverageChanged
ArtemGovorov commented 7 years ago

Looks like we have found it: C:\Users\p.steinebrunner\node_modules\@ngrx. This location must have v2 installed. Try removing it from there.

philipooo commented 7 years ago

God damn, why is there a node_modules folder just containing that module @ v2. @ArtemGovorov you are my hero! Thank you very much for your awesome support!

ArtemGovorov commented 7 years ago

Awesome, thanks for the update!