When I was writing unit tests against the webpart class, I get an error that the @ms/sp-telemetry
is missing.
While running gulp test
I receive the following error:
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
Error: Cannot find module "@ms/sp-telemetry"
at /Users/<user>/nodejs/spfx/testing-wp/temp/tests.js:52957
describe('<HelloWorldWebPart />', () => {
it('Should open the webpart', () => {
const mockCtx = new MockWebPartContext();
const wp = mockCtx.initialize(new HelloWorldWebPart());
});
});
When I write this in a test I get the error. When I remove const wp = mockCtx.initialize(new HelloWorldWebPart());
, all other tests keep working.
When you just do something like this const wp = new HelloWorldWebPart()
you get the same error.
@estruyf are you still seeing this issue?
Yes, still the same missing dependency.
Also the same in the new update.
Yes, still the same missing dependency.
This is a known issue. We're working on a solution.
I have the same error on test running if I import in the code:
import { HttpClient } from "@microsoft/sp-http";
Is there a workaround for this issue?
We also have the same problem and need a workaround for this issue.
Have the same issue when running tests
Module not found: Error: Can't resolve ms sp-telemetry
any help ?
Uncaught Error: Cannot find module "@ms/sp-telemetry" at webpackMissingModule
Upgraded to latest sharepoint yoeman generator, and still getting this issue. I have removed node_modules folder, tried npm install / npm install --save-dev. Tried gulp clean. Module still missing.
Is there any update on this issue? Has anyone got around this issue and have a workaround?
Edit [Add version details]
microsoft/[email protected]
npm 3.10.10
node v6.10.2
Update:
Isolated my occurrence to "sp-pnp-js": "2.0.6".
Will do an update to version 2.0.7 and get back with the results.
Update:
Issue for me is resolved by update to sp-pnp-js 2.0.7
I have run the following command to see packages
λ npm -g list --depth=0
removed and installed again updated [email protected] and [email protected]
still having issues
Also having issues with this.
Hi All, after some debugging and following @buckyaustin update.
I found that there was a duplicate @assets import within my WebPart, when I remove this the error "Module not found: Error: Can't resolve ms sp-telemetry" was gone and my unit tests started working again.
Not working me .. anu update
Same here. Any updates on this?
@iclanton Can you provide an update on this?
Would be greatly appreciated :).
I checked and found that every method which is making a calll the http service needs to be stub
and it worked for me
@deploymentvsureshk Could be so kind as to create an example (HelloWorld WebPart) to demonstrate it?
Further information that might help.
I have seen this occur on the following
@ microsoft/sp-loader.SPComponentLoader.loadCss
@ microsoft/sp-loader.SPComponentLoader.loadScript
@ microsoft/sp-http.HttpClient
sp-pnp-js.pnp.web.lists
Just using the import statement for these doesn't cause the problem, but using methods within them causes the problem to occur.
I'm assuming there is a common class/method that all of these use that is causing the problem.
You should stub responses from ajax or switch out a class that does the http call for another class that doesn't use http. In my build we switch classes so the http code doesn't get executed. Just by having the methods used in the code base is enough to cause the tests to fail even though they are not invoked in the tests. Commenting out the use of the methods allows gulp test to execute.
Hope this information helps.
Hey I am getting the same error as well. Version 1.2.0 of the SPFx. Seems that @ms/sp-telemetry
package is included with almost all the SPFx libraries. When gulp test
is run in the temp folder we get manifest and the @ms/sp-telemetry
is hooked to almost every SPFx Library and Application including SPLoader, SPHttp, SPPageContext, SPComponentBase, SPWebPartBase, SPExtensionBase, WebPartWorkbench, SPLoader. However if we go to the SPFx node modules and reverse engeneer for a while we see that this is package is from internal Microsoft NPM server.
"description": "An internal package supporting the SharePoint Framework",
"devDependencies": {
"@ms/odsp-utilities-bundle": "~1.1.0",
"@ms/sp-build-internal-web": "~0.6.1",
"@ms/sp-telemetry": "~0.2.2",
"@types/chai": "3.4.34",
"@types/mocha": "2.2.38",
"@types/sinon": "1.16.34",
"@uifabric/styling": "0.15.2",
"chai": "~3.5.0",
"gulp": "~3.9.1",
"sinon": "~1.17.6"
}
Please remove that package from the loaderConfig so we can test or make it publicly available. Thanks!
This also affects "@microsoft/sp-dialog" where the internal "@ms/sp-telemetry": "~0.2.2" is in the dev dependencies, But is used extensively in the code.
The missing class is a class to do some logging.
IMHO, It should be moved to the dependencies (from dev) for the module and made public, or all references to the logger should be removed, or a stub alternate provided.
My versions are:
"@microsoft/decorators": "~1.3.0",
"@microsoft/sp-application-base": "1.3.0",
"@microsoft/sp-core-library": "~1.3.0",
"@microsoft/sp-dialog": "1.3.0",
"@microsoft/sp-http": "^1.2.0",
"@microsoft/sp-lodash-subset": "~1.3.0",
"@microsoft/sp-webpart-base": "~1.3.0",
Another observation is that if you try for some reason to create/test new instance of class that uses SPComponentLoader
within .test.ts file then it will throw the @ms/sp-telemetry
error and fail all tests. By removing such classes and replacing with mock-ed classes that do now have the reference to SPComponentLoader
might partially solve the issue.
I also get this error if I do this import:
import { SPHttpClient, SPHttpClientResponse } from '@microsoft/sp-http';
@YonasJ
I also faced same issue. But what i am having in my .ts file is
import SPHttpClient from '@microsoft/sp-http/lib/spHttpClient/SPHttpClient';
import SPHttpClientResponse from '@microsoft/sp-http/lib/spHttpClient/SPHttpClientResponse';
Since I am importing spHttpClient twice even though for different modules, it is giving error. If I change to import {SPHttpClient,SPHttpClientResponse} from '@microsoft/sp-http';
then it started working.
Hope this is helpful.
@ymihir solution worked for me as well.
With 1.3 this issue prevents testing of spHttpClient.
@VesaJuvonen - I see this is among the 6 issues still marked as 'status:fixed-next-drop'. Can someone tell me what that means from an ETA standpoint?
I can reproduce issue in spfx 1.4.0.
Hi,
Thank you for the feedback. Please add a feature request on UserVoice and depending on community interest we may or may not be able to make the fix.
@lahuey - Please correct me if I'm mistaken, but I don't think this is a feature request - it's a bug.
Is this fixed in 1.4.1?
@michel-weber We're still experiencing this issue in 1.4.1.
I saw the tag _status:fixed-next-drop_ so I was under the impression that a fix would be rolled out soon. Is that not the case?
If this has been de-prioritized, does anyone know of any docs/blogs explaining how to work around this? This issue is blocking my team from doing any testing on web parts which include REST calls (all of our components do). Thanks for any info.
That was also my understanding. But the tag was added on the 28th of October 2017 - and since then 1.4.0 and 1.4.1 have been released. So I think this issue should be reopened.
@VesaJuvonen Can you look into this? Will this fix be released with the next version (> 1.4.1)?
I think @lahuey is silently saying "Deal with it" :) . It has always been convenient to turn bug into a feature :) . Considering the fact that the testing scaffold templates are not in the latest framework anymore and the last comment from @patmill here https://github.com/SharePoint/sp-dev-docs/issues/1335. I am not sure if we should still rely on the testing framework that comes with the frameworks anymore.
I have added a UserVoice to prioritise getting this fixed. Please up-vote it if you are interested as well.
I have the same problem with import { GraphHttpClient, HttpClientResponse} from '@microsoft/sp-http';
Error: Cannot find module "@ ms/sp-telemetry"
have you resolve this problem ?
We are running into the same issue here
Cannot find module '@ms/sp-telemetry' from 'DigestCache.js'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:179:17)
at Object.
This is due to if you have any http reference used for TEST
On Saturday, 7 July, 2018, 1:15:53 AM IST, Devin Prejean notifications@github.com wrote:
Sorry for the double post but I took another stab at my issue and found a fix for me, not a workaround.
Seems I was referencing imports from the same folder, however one group was listed in my index, the other was referenced all the way. For example:
import { ModuleName } From "./provider/module
import { SecondModule } from "./provider"
once i changed the second module to reference all the way instead of using the index.ts file inside the folder my issue went away.
Hope this helps someone.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
I'm running into a similar issue:
Cannot find module "@ms/sp-client-shared" which is being referenced under "..\node_modules\@microsoft\sp-http\lib\oauthTokenProvider\OAuthTokenProvider.js"
Hey @adambarrettsmith . I'm running into a similar issue. Wondering if you could update this thread if you found a workaround. Thanks!
For the record:
I was experiencing this on 1.4.1
, and ultimately ended up upgrading to 1.6.0-plusbeta
which seems to have eliminated the problem.
(Recommendation: use office365-cli
to retrieve steps for doing this upgrade, as there are a bunch of minor manual config changes it reports)
I am getting this error Cannot find module '@ms/sp-client-shared' from 'OAuthTokenProvider.js
when I try to run tests for services that use SPHttpClient
for rest calls.
In my jest configuration I have as below as it was giving me Unexpected token error
when jest compiles the service class.
"transformIgnorePatterns": [ "node_modules/(?!(@microsoft/sp-http)|(@microsoft/sp-core-library)|(@microsoft/sp-diagnostics))" ],
I am not sure if this is the right way but any help or direction in this space would be helpful as I am new to writing tests.
I am using Sinon stubs to mock the functions.
The tests work when using axios
instead of SPHttpClient
Dear all I am running into this problem when I try to debug a spfx react web part Cannot find module '@ms/sp-telemetry'
Can someone help?
Has this been resolved? I am on SPFx v1.8.0 and I am seeing missing dependencies when trying to unit test my web parts (which are not using React) using Jest. Specifically I am seeing _Cannot find module '@ms/sp-telemetry' from 'SPStarter.js'_ when trying to import SPComponentLoader from @microsoft/sp-loader in my web part. If I remove that from my web part, I then encounter another error: _Cannot find module '@ms/sp-client-shared' from 'OAuthTokenProvider.js'_.
Am I missing something? Thanks in advance!
Running into the same issue for unit tests in SPFx using jest/sinon.
One of the react components use
import { SPComponentLoader } from '@microsoft/sp-loader';
Tests fail with message
● Test suite failed to run
Cannot find module '@ms/sp-telemetry' from 'SPStarter.js'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:169:17)
at Object.<anonymous> (node_modules/@microsoft/sp-loader/lib/SPStarter.js:4:22)
SPFx version 1.8.2
jest : 24.8.0
npm : 6.9.0
node : 10.15.3
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues
Most helpful comment
This is a known issue. We're working on a solution.