Skip to content

Commit

Permalink
Merge pull request #205 from 10up/upkeep/199
Browse files Browse the repository at this point in the history
Migrate to Cypress 11
  • Loading branch information
iamdharmesh authored Dec 9, 2022
2 parents 4690d02 + 8bd71de commit 997d3c7
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 80 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:

jobs:
build:
uses: 10up/autoshare-for-twitter/.github/workflows/build-release-zip.yml@try/release-e2e # TODO: Update this to develop branch.
uses: 10up/autoshare-for-twitter/.github/workflows/build-release-zip.yml@develop

cypress:
needs: build
Expand Down Expand Up @@ -61,10 +61,13 @@ jobs:
run: npm run env:start

- name: Test
run: |
npm i -g [email protected]
cypress run --config-file tests/cypress/config.json --env TWITTER_API_KEY=${{ secrets.TWITTER_API_KEY }},TWITTER_API_SECRET=${{ secrets.TWITTER_API_SECRET }},TWITTER_ACCESS_TOKEN=${{ secrets.TWITTER_ACCESS_TOKEN }},TWITTER_ACCESS_SECRET=${{ secrets.TWITTER_ACCESS_SECRET }}
run: npm run cypress:run
env:
CYPRESS_TWITTER_API_KEY: ${{ secrets.TWITTER_API_KEY }}
CYPRESS_TWITTER_API_SECRET: ${{ secrets.TWITTER_API_SECRET }}
CYPRESS_TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
CYPRESS_TWITTER_ACCESS_SECRET: ${{ secrets.TWITTER_ACCESS_SECRET }}

- name: Upload artifacts
uses: actions/upload-artifact@v2
if: failure()
Expand Down
56 changes: 28 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"env:start": "wp-env start",
"env:stop": "wp-env stop",
"postenv:start": "./tests/bin/initialize.sh",
"cypress:open": "cypress open --config-file tests/cypress/config.json",
"cypress:run": "cypress run --config-file tests/cypress/config.json",
"cypress:open": "cypress open --config-file tests/cypress/cypress.config.js --e2e --browser chrome",
"cypress:run": "cypress run --config-file tests/cypress/cypress.config.js",
"lint": "eslint ."
},
"husky": {
Expand Down Expand Up @@ -42,12 +42,12 @@
"@babel/core": "^7.6.0",
"@babel/preset-env": "^7.6.0",
"@babel/preset-react": "^7.0.0",
"@wordpress/env": "^5.4.0",
"@wordpress/env": "^5.7.0",
"@wordpress/eslint-plugin": "^3.0.0",
"@wordpress/prettier-config": "^1.1.1",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.6",
"cypress": "^9.0.0",
"cypress": "^11.2.0",
"eslint": "^6.3.0",
"husky": "^3.0.5",
"lint-staged": "^9.2.5",
Expand Down
10 changes: 0 additions & 10 deletions tests/cypress/config.json

This file was deleted.

38 changes: 38 additions & 0 deletions tests/cypress/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const { defineConfig } = require('cypress');
const { readConfig } = require('@wordpress/env/lib/config');

module.exports = defineConfig({
fixturesFolder: 'tests/cypress/fixtures',
screenshotsFolder: 'tests/cypress/screenshots',
videosFolder: 'tests/cypress/videos',
downloadsFolder: 'tests/cypress/downloads',
video: false,
e2e: {
setupNodeEvents(on, config) {
return setBaseUrl(on, config);
},
specPattern: 'tests/cypress/e2e/**/*.test.{js,jsx,ts,tsx}',
supportFile: 'tests/cypress/support/e2e.js',
},
});

/**
* Set WP URL as baseUrl in Cypress config.
*
* @param {Function} on function that used to register listeners on various events.
* @param {object} config Cypress Config object.
* @returns config Updated Cypress Config object.
*/
const setBaseUrl = async (on, config) => {
const wpEnvConfig = await readConfig('wp-env');

if (wpEnvConfig) {
const port = wpEnvConfig.env.tests.port || null;

if (port) {
config.baseUrl = wpEnvConfig.env.tests.config.WP_SITEURL;
}
}

return config;
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
33 changes: 0 additions & 33 deletions tests/cypress/plugins/index.js

This file was deleted.

File renamed without changes.

0 comments on commit 997d3c7

Please sign in to comment.