Upgrade to 1.5.0, missing launch.json config added (#530)

This commit is contained in:
Velin Georgiev 2018-06-15 06:46:43 +01:00 committed by Vesa Juvonen
parent 9c7e33b521
commit 0af385ed17
16 changed files with 3373 additions and 2090 deletions

View File

@ -1,8 +1,11 @@
{ {
"@microsoft/generator-sharepoint": { "@microsoft/generator-sharepoint": {
"version": "1.4.1", "isCreatingSolution": true,
"version": "1.5.0",
"libraryName": "react-jest-testing", "libraryName": "react-jest-testing",
"libraryId": "9e16e13b-8d8c-4b89-8de4-dd654c5b6740", "libraryId": "9e16e13b-8d8c-4b89-8de4-dd654c5b6740",
"environment": "spo" "environment": "spo",
"packageManager": "npm",
"componentType": "webpart"
} }
} }

View File

@ -15,6 +15,10 @@ There is also a _Jest Watch_ (watcher) configuration that **will let live execut
![SharePoint Framework Jest Visual Studio Code - debugging unit test](./assets/Jest-Typescript-VSCode-debugging.png) ![SharePoint Framework Jest Visual Studio Code - debugging unit test](./assets/Jest-Typescript-VSCode-debugging.png)
### Important: The dedug configurations should be placed in the .vscode -> launch.json file to make the debugging work
The sample has folder named `vscode` where the `launch.json` configuration for debuggind jest is stored. The configurations should be copied to your `.vscode` folder -> `launch.json` file. Once copied into your launch.json, then they will appear in your visual studio code debugging tab.
## Sinonjs is included as mocking framework for the SPFx solution ## Sinonjs is included as mocking framework for the SPFx solution
The solution also includes [Sinonjs](http://sinonjs.org/) that can be used to spawn spies, stubs and mocks. The solution also includes [Sinonjs](http://sinonjs.org/) that can be used to spawn spies, stubs and mocks.
@ -58,7 +62,7 @@ The sample uses SPFx web part, but the same setup applies for SPFx extensions an
## Used SharePoint Framework Version ## Used SharePoint Framework Version
![drop](https://img.shields.io/badge/drop-1.4.1-green.svg) ![drop](https://img.shields.io/badge/drop-1.5.0-green.svg)
## Applies to ## Applies to
@ -81,6 +85,7 @@ react-jest-testing | Velin Georgiev ( [@VelinGeorgiev](https://twitter.com/velin
Version|Date|Comments Version|Date|Comments
-------|----|-------- -------|----|--------
0.0.1|May 9, 2018 | Initial commit 0.0.1|May 9, 2018 | Initial commit
0.0.2|June 12, 2018 | Update to 1.5.0, missing launch.json added
## Disclaimer ## Disclaimer
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.** **THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**

View File

@ -1,5 +1,5 @@
{ {
"$schema": "https://dev.office.com/json-schemas/spfx-build/config.2.0.schema.json", "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
"version": "2.0", "version": "2.0",
"bundles": { "bundles": {
"ice-cream-shop-web-part": { "ice-cream-shop-web-part": {

View File

@ -1,4 +1,4 @@
{ {
"$schema": "https://dev.office.com/json-schemas/spfx-build/copy-assets.schema.json", "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/copy-assets.schema.json",
"deployCdnPath": "temp/deploy" "deployCdnPath": "temp/deploy"
} }

View File

@ -1,5 +1,5 @@
{ {
"$schema": "https://dev.office.com/json-schemas/spfx-build/deploy-azure-storage.schema.json", "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
"workingDir": "./temp/deploy/", "workingDir": "./temp/deploy/",
"account": "<!-- STORAGE ACCOUNT NAME -->", "account": "<!-- STORAGE ACCOUNT NAME -->",
"container": "react-jest-testing", "container": "react-jest-testing",

View File

@ -1,5 +1,5 @@
{ {
"$schema": "https://dev.office.com/json-schemas/spfx-build/package-solution.schema.json", "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": { "solution": {
"name": "react-jest-testing-client-side-solution", "name": "react-jest-testing-client-side-solution",
"id": "9e16e13b-8d8c-4b89-8de4-dd654c5b6740", "id": "9e16e13b-8d8c-4b89-8de4-dd654c5b6740",

View File

@ -1,5 +1,5 @@
{ {
"$schema": "https://dev.office.com/json-schemas/core-build/serve.schema.json", "$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
"port": 4321, "port": 4321,
"https": true, "https": true,
"initialPage": "https://localhost:5432/workbench", "initialPage": "https://localhost:5432/workbench",

View File

@ -1,5 +1,5 @@
{ {
"$schema": "https://dev.office.com/json-schemas/core-build/tslint.schema.json", "$schema": "https://developer.microsoft.com/json-schemas/core-build/tslint.schema.json",
// Display errors as warnings // Display errors as warnings
"displayAsWarning": true, "displayAsWarning": true,
// The TSLint task may have been configured with several custom lint rules // The TSLint task may have been configured with several custom lint rules

View File

@ -1,4 +1,4 @@
{ {
"$schema": "https://dev.office.com/json-schemas/spfx-build/write-manifests.schema.json", "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
"cdnBasePath": "<!-- PATH TO CDN -->" "cdnBasePath": "<!-- PATH TO CDN -->"
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "react-jest-testing", "name": "react-jest-testing",
"version": "0.0.1", "version": "0.0.2",
"private": true, "private": true,
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=0.10.0"
@ -15,32 +15,33 @@
"react-dom": "15.6.2", "react-dom": "15.6.2",
"@types/react": "15.6.6", "@types/react": "15.6.6",
"@types/react-dom": "15.5.6", "@types/react-dom": "15.5.6",
"@microsoft/sp-core-library": "~1.4.1", "@microsoft/sp-core-library": "1.5.0",
"@microsoft/sp-webpart-base": "~1.4.1", "@microsoft/sp-webpart-base": "1.5.0",
"@microsoft/sp-lodash-subset": "~1.4.1", "@microsoft/sp-lodash-subset": "1.5.0",
"@microsoft/sp-office-ui-fabric-core": "~1.4.1", "@microsoft/sp-office-ui-fabric-core": "1.5.0",
"@types/webpack-env": ">=1.12.1 <1.14.0", "@types/webpack-env": "1.13.1",
"@pnp/common": "1.0.4", "@types/es6-promise": "0.0.33",
"@pnp/sp": "1.0.4", "@pnp/common": "1.1.1",
"@pnp/odata": "1.0.4", "@pnp/sp": "1.1.1",
"@pnp/logging": "1.0.4" "@pnp/odata": "1.1.1",
"@pnp/logging": "1.1.1"
}, },
"devDependencies": { "devDependencies": {
"@microsoft/sp-build-web": "~1.4.1", "@microsoft/sp-build-web": "1.5.0",
"@microsoft/sp-module-interfaces": "~1.4.1", "@microsoft/sp-module-interfaces": "1.5.0",
"@microsoft/sp-webpart-workbench": "~1.4.1", "@microsoft/sp-webpart-workbench": "1.5.0",
"gulp": "~3.9.1", "gulp": "~3.9.1",
"@types/chai": ">=3.4.34 <3.6.0", "@types/chai": "3.4.34",
"@types/mocha": ">=2.2.33 <2.6.0", "@types/mocha": "2.2.38",
"ajv": "~5.2.2", "ajv": "~5.2.2",
"@types/jest": "22.2.3", "@types/jest": "22.2.3",
"jest": "22.4.3", "jest": "22.4.3",
"ts-jest": "22.4.5", "ts-jest": "22.4.5",
"identity-obj-proxy": "3.0.0", "identity-obj-proxy": "3.0.0",
"react-test-renderer": "15.6.2",
"enzyme": "3.3.0", "enzyme": "3.3.0",
"@types/enzyme": "3.1.10", "@types/enzyme": "3.1.10",
"enzyme-adapter-react-15": "1.0.5", "enzyme-adapter-react-15": "1.0.5",
"react-test-renderer": "15.6.2",
"@types/sinon": "4.3.1", "@types/sinon": "4.3.1",
"sinon": "5.0.7", "sinon": "5.0.7",
"jest-junit": "3.7.0" "jest-junit": "3.7.0"
@ -57,7 +58,6 @@
"testMatch": [ "testMatch": [
"**/src/**/*.test.+(ts|tsx|js)" "**/src/**/*.test.+(ts|tsx|js)"
], ],
"mapCoverage": true,
"collectCoverage": true, "collectCoverage": true,
"coverageReporters": [ "coverageReporters": [
"json", "json",

View File

@ -1,5 +1,5 @@
{ {
"$schema": "https://dev.office.com/json-schemas/spfx/client-side-web-part-manifest.schema.json", "$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
"id": "d67c5975-ba3e-49ec-9a23-245c15ea3cda", "id": "d67c5975-ba3e-49ec-9a23-245c15ea3cda",
"alias": "IceCreamShopWebPart", "alias": "IceCreamShopWebPart",
"componentType": "WebPart", "componentType": "WebPart",

View File

@ -12,7 +12,7 @@ export class IceCreamPnPJsProvider implements IIceCreamProvider {
public getAll(): Promise<IceCream[]> { public getAll(): Promise<IceCream[]> {
return new Promise<IceCream[]>(async (resolve, reject) => { return new Promise<IceCream[]>((resolve, reject) => {
const query: SearchQuery = { const query: SearchQuery = {
RowLimit: 10, RowLimit: 10,

View File

@ -44,12 +44,15 @@ describe('Enzyme basics', () => {
it('should has the correct title', () => { it('should has the correct title', () => {
// Arrange
// define contains/like css selector // define contains/like css selector
let cssSelector: string = 'h1'; let cssSelector: string = 'h1';
// Act
// find the elemet using css selector // find the elemet using css selector
const text = reactComponent.find(cssSelector).text(); const text = reactComponent.find(cssSelector).text();
// Assert
expect(text).toBe("PnP Ice Cream Shop"); expect(text).toBe("PnP Ice Cream Shop");
}); });
}); });

View File

@ -2,7 +2,8 @@
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es5",
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"module": "commonjs", "module": "esnext",
"moduleResolution": "node",
"jsx": "react", "jsx": "react",
"declaration": true, "declaration": true,
"sourceMap": true, "sourceMap": true,

View File

@ -0,0 +1,73 @@
{
/**
* Install Chrome Debugger Extension for Visual Studio Code to debug your components with the
* Chrome browser: https://aka.ms/spfx-debugger-extensions
*/
"version": "0.2.0",
"configurations": [
{
"name": "Local workbench",
"type": "chrome",
"request": "launch",
"url": "https://localhost:4321/temp/workbench.html",
"webRoot": "${workspaceRoot}",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///../../../src/*": "${webRoot}/src/*",
"webpack:///../../../../src/*": "${webRoot}/src/*",
"webpack:///../../../../../src/*": "${webRoot}/src/*"
},
"runtimeArgs": [
"--remote-debugging-port=9222"
]
},
{
"name": "Hosted workbench",
"type": "chrome",
"request": "launch",
"url": "https://enter-your-SharePoint-site/_layouts/workbench.aspx",
"webRoot": "${workspaceRoot}",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///../../../src/*": "${webRoot}/src/*",
"webpack:///../../../../src/*": "${webRoot}/src/*",
"webpack:///../../../../../src/*": "${webRoot}/src/*"
},
"runtimeArgs": [
"--remote-debugging-port=9222",
"-incognito"
]
},
//https://github.com/Microsoft/vscode-recipes/tree/master/debugging-jest-tests
//https://github.com/facebook/jest/issues/1652
{
"type": "node",
"request": "launch",
"name": "Jest All",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": ["--runInBand"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"type": "node",
"request": "launch",
"name": "Jest Watch",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": ["--runInBand","--watch"], // jest --watch #runs jest -o by default
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
//https://facebook.github.io/jest/docs/en/cli.html
"type": "node",
"request": "launch",
"name": "Jest Watch All",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": ["--runInBand","--watchAll"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}