Skip to content

Commit 7942dd4

Browse files
committed
add jest tests plus slack-alert refactor and CLI options
1 parent 5e0484d commit 7942dd4

28 files changed

+4715
-599
lines changed

e2e/.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ logs
55
.scannerwork
66
reports
77
videos
8-
screenshots
8+
screenshots
9+
coverage
10+
testReports

e2e/cypress/support/commands.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,28 @@ declare global {
2929
* @memberof Cypress.Chainable
3030
*
3131
* @example
32-
```
33-
cy.sum(2, 3).should('equal', 5)
34-
```
32+
* ```
33+
* cy.sum(2, 3).should('equal', 5)
34+
* ```
3535
*/
3636
sum: (a: number, b: number) => Chainable<number>
3737

3838
/**
3939
* Example command that passes an object of arguments.
4040
* @memberof Cypress.Chainable
4141
* @example
42-
```
43-
cy.greeting({ greeting: 'Hello', name: 'Friend' })
44-
// or use defaults
45-
cy.greeting()
46-
```
42+
* ```
43+
* cy.greeting({ greeting: 'Hello', name: 'Friend' })
44+
* // or use defaults
45+
* cy.greeting()
46+
* ```
4747
*/
4848
greeting: (options?: Greeting) => void
4949
}
5050
}
5151
}
5252

53-
/**
53+
/**
5454
* An example function "foo()"
5555
*
5656
* @returns {string} "foo"
@@ -74,7 +74,7 @@ export function foo2() {
7474
/**
7575
* Adds two numbers
7676
* @example sum(2, 3) // 5
77-
*/
77+
*/
7878
export function sum(a: number, b: number): number {
7979
return a + b
8080
}
@@ -90,6 +90,7 @@ const defaultGreeting: Cypress.Greeting = {
9090
*/
9191
export const printToConsole = (options = defaultGreeting) => {
9292
const {greeting, name} = options
93+
// tslint:disable-next-line: no-console
9394
console.log(`${greeting}, ${name}`)
9495
}
9596

e2e/cypress/support/step_definitions/examples/customParameterTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ defineParameterType({
1717

1818
let keySound: string
1919

20+
// tslint:disable-next-line: variable-name
2021
When("I press the {ordinal} key of my piano", (number: number) => {
2122
keySound = notes[(number - 1) % 7];
2223
});

e2e/cypress/support/step_definitions/examples/docString.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ When("I use DocString for code like this:", (dataString: string) => {
88
});
99

1010
When("I ran it and verify that it executes it", () => {
11+
// tslint:disable-next-line: no-eval
1112
eval(code);
1213
expect(variableToVerify).to.equal("hello world");
1314
});

e2e/cypress/support/step_definitions/examples/importingFiles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Given, Then, When } from "cypress-cucumber-preprocessor/steps";
22

33
import defaultData, { namedData } from "./importingFilesData";
44

5+
// tslint:disable-next-line: no-empty
56
Given(`I imported a file`, () => {});
67

78
Then(`I can access imported file data`, () => {

e2e/cypress/support/step_definitions/examples/webpack.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Given, Then, When } from "cypress-cucumber-preprocessor/steps";
22
import myAssertion from "../../helpers/myAssertion";
33

44

5+
// tslint:disable-next-line: no-empty
56
Given(`webpack is configured`, () => {});
67

78
Then(`this test should work just fine!`, () => {

e2e/cypress/support/step_definitions/login.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Given('I have loaded the internet page', () => {
55
login.visit()
66
})
77

8+
// tslint:disable-next-line: no-empty
89
Given('I am a user', () => {
910
})
1011

e2e/cypress/tsconfig.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compilerOptions": {
3+
"types": ["node","@slack/types","cypress","cypress-testing-library"],
4+
"module": "commonjs",
5+
"skipLibCheck": true,
6+
"strict": true,
7+
"target": "es5",
8+
"baseUrl": "../node_modules" // needed if your tests import npm modules
9+
},
10+
"include": [
11+
"../node_modules/cypress/types",
12+
"../node_modules/cypress-testing-library/typings",
13+
"**/*.ts", "../untyped.d.ts"
14+
]
15+
,
16+
"exclude": [
17+
"../node_modules/@types/jest/*",
18+
]
19+
}

e2e/jest.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
globals: {
3+
"ts-jest": {
4+
tsConfig: "tsconfig.json"
5+
}
6+
},
7+
testRegex: "scripts/slack/.*.test.ts",
8+
moduleFileExtensions: ["ts", "js"],
9+
transform: {
10+
"\\.ts": "ts-jest"
11+
},
12+
testEnvironment: "node",
13+
reporters: ["default", "jest-junit"],
14+
coverageDirectory: "./coverage",
15+
collectCoverage: true
16+
};

e2e/package.json

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"author": "Yousaf Nabi",
88
"license": "ISC",
99
"scripts": {
10-
"lint":"tslint --project .",
11-
"lint-fix":"tslint --project . --fix",
10+
"lint": "tslint --project .",
11+
"lint-fix": "tslint --project . --fix",
1212
"cypress:open": "cypress open",
1313
"cypress:run": "cypress run",
1414
"cypress:record": "cypress run --record",
@@ -22,33 +22,39 @@
2222
"@cypress/webpack-preprocessor": "^4.0.3",
2323
"@slack/types": "^1.0.0",
2424
"@slack/webhook": "^5.0.0",
25+
"@types/jest": "^24.0.11",
2526
"@types/node": "^10.12.11",
27+
"commander": "^2.20.0",
2628
"cypress": "^3.2.0",
29+
"cypress-cucumber-preprocessor": "1.11.0",
2730
"cypress-failed-log": "^2.5.0",
31+
"cypress-testing-library": "2.4.0",
2832
"husky": "^1.3.1",
33+
"jest": "^24.7.1",
34+
"jest-junit": "^6.3.0",
35+
"jest-stare": "^1.13.2",
2936
"lint-staged": "^8.1.5",
30-
"prettier": "^1.16.4",
3137
"mocha": "^5.2.0",
3238
"mocha-junit-reporter": "^1.21.0",
3339
"mocha-multi-reporters": "^1.1.7",
3440
"mochawesome": "^3.1.1",
3541
"mochawesome-merge": "^1.0.7",
3642
"mochawesome-report-generator": "^3.1.5",
43+
"npm-run-all": "4.1.5",
44+
"prettier": "^1.16.4",
45+
"serve": "11.0.0",
3746
"shelljs": "^0.8.3",
3847
"sonarqube-scanner": "^2.4.0",
48+
"ts-jest": "^24.0.2",
3949
"ts-loader": "^5.3.3",
4050
"ts-node": "^8.0.3",
4151
"tslint": "^5.15.0",
4252
"tslint-config-prettier": "1.18.0",
4353
"tslint-no-focused-test": "^0.5.0",
4454
"typescript": "^3.4.1",
4555
"uuid": "^3.3.2",
46-
"webpack": "^4.29.6",
47-
"cypress-cucumber-preprocessor": "1.11.0",
48-
"cypress-testing-library": "2.4.0",
49-
"npm-run-all": "4.1.5",
50-
"serve": "11.0.0",
51-
"wait-port": "0.2.2"
56+
"wait-port": "0.2.2",
57+
"webpack": "^4.29.6"
5258
},
5359
"cypress-cucumber-preprocessor": {
5460
"nonGlobalStepDefinitions": false
@@ -64,5 +70,13 @@
6470
"hooks": {
6571
"pre-commit": "lint-staged"
6672
}
73+
},
74+
"jest-stare": {
75+
"coverageLink": "../lcov-report/index.html",
76+
"resultDir": "coverage/html"
77+
},
78+
"jest-junit": {
79+
"outputDirectory": "./testReports/",
80+
"reportDir": "testReports/unit"
6781
}
6882
}

0 commit comments

Comments
 (0)