Skip to content

Commit

Permalink
Merge pull request #291 from dhis2/Fix_networkshim_getFeatureName_util
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammer5 authored Nov 4, 2021
2 parents b6594af + 923f42d commit 31b8118
Show file tree
Hide file tree
Showing 10 changed files with 3,090 additions and 2,407 deletions.
3 changes: 3 additions & 0 deletions examples/testing-network-shim-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"react-scripts": "4.0.1",
"web-vitals": "^0.2.4"
},
"devDependencies": {
"cypress": "^8.2"
},
"scripts": {
"serve": "json-server src/json-server/db.js --routes ./src/json-server/routes.json --middlewares ../../node_modules/json-server-reset --watch -p 1337",
"start": "react-scripts start",
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
"docs:start": "d2-utils-docsite serve ./docs -o ./dist",
"build": "yarn workspace @dhis2/cypress-commands build",
"watch": "yarn workspace @dhis2/cypress-commands build --watch",
"test": "jest",
"test": "yarn test:cli && yarn test:commands && yarn test:plugins",
"test:cli": "yarn workspace @dhis2/cli-utils-cypress test",
"test:commands": "yarn workspace @dhis2/cypress-commands test",
"test:plugins": "exit 0 # no tests yet",
"test:network-shim-app": "yarn workspace testing-network-shim-app cy:capture-and-stub",
"test:platform-app": "yarn workspace platform-app cy:capture-and-stub",
"cy:local": "yarn build && yarn test:network-shim-app && yarn test:platform-app"
Expand All @@ -44,7 +47,6 @@
"concurrently": "^6.2.0",
"eslint-plugin-cypress": "^2.11.2",
"eslint-plugin-prettier": "^3.2.0",
"jest": "^26.6.3",
"wait-on": "^5.3.0"
},
"d2": {
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
roots: ['./src', './codemods'],
}
10 changes: 8 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"bin": {
"d2-utils-cypress": "./bin/d2-utils-cypress"
},
"scripts": {
"test": "d2-app-scripts test"
},
"main": "src/index.js",
"version": "8.0.6",
"author": "Viktor Varland <viktor@dhis2.org>",
Expand All @@ -19,11 +22,14 @@
},
"dependencies": {
"@dhis2/cli-helpers-engine": "^2.3.0",
"cypress": "^7.4.0",
"cypress-cucumber-preprocessor": "^2.0.1",
"fs-extra": "^8.1.0",
"jscodeshift": "^0.11.0"
},
"devDependencies": {
"@dhis2/cli-app-scripts": "^6.2.0",
"cypress": "^8.2",
"cypress-cucumber-preprocessor": "^4"
},
"publishConfig": {
"access": "public"
}
Expand Down
3 changes: 3 additions & 0 deletions packages/cypress-commands/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
roots: ['./src', './codemods'],
}
8 changes: 6 additions & 2 deletions packages/cypress-commands/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@
"access": "public"
},
"scripts": {
"build": "d2-app-scripts build"
"build": "d2-app-scripts build",
"test": "d2-app-scripts test"
},
"devDependencies": {
"@dhis2/cli-app-scripts": "^6.2.0"
},
"peerDependencies": {
"cypress": "^7",
"cypress": "^8.2",
"cypress-cucumber-preprocessor": "^4"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ export const splitHostAndPath = (url, hosts) => {
}

export const getFeatureName = () => {
let obj = Cypress.mocha.getRunner().suite.ctx.test
let title = null
while (obj && obj.parent && obj.parent.title) {
obj = obj.parent
title = obj.title
}
return title
return Cypress.currentTest.titlePath[0]
}

export const toJsonBlob = async input => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { getFeatureName } = require('./utils.js')

describe('getFeatureName', () => {
beforeEach(() => {
global.Cypress = {
title: 'bar',
currentTest: {
titlePath: ['foo', 'bar'],
},
}
})

it('should use firtst item of the titlePath of the current test', () => {
expect(getFeatureName()).toBe('foo')
})
})
8 changes: 7 additions & 1 deletion packages/cypress-plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@
"url": "https://github.com/dhis2/cli-utils-cypress.git",
"folder": "packages/cypress-plugins"
},
"scripts": {
"test": "d2-app-scripts test"
},
"author": "Jan-Gerke Salomon",
"license": "BSD-3-Clause",
"private": false,
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@dhis2/cli-app-scripts": "^6.2.0"
},
"peerDependencies": {
"cypress": "^7",
"cypress": "^8.2",
"cypress-cucumber-preprocessor": "^4"
}
}
5,432 changes: 3,039 additions & 2,393 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit 31b8118

Please sign in to comment.