Cypress intercept and wait not working on GitHub Actions - cypress

All my tests are running and passing as expected locally; however, there is one test that is failing when running on GitHub actions. The error I'm getting is:
CypressError: Timed out retrying after 60000ms:
`cy.wait()` timed out waiting `60000ms` for the 1st request to the route:
`addCustomerMutation`. No request ever occurred.
My code looks like this:
// IMPORTS
cy.intercept('POST', URL, (req) => {
delete req.headers['if-none-match'];
const addCustomerOp = 'addCustomerMutation';
const { body } = req;
if (body.hasOwnProperty('operationName' && body.operationName === addCustomerOp) {
req.alias = addCustomerOp;
req.reply({ data: addCustomer });
}
});
// FILL UP A FORM
cy.get('[data-testid="customer-save-button"]').click();
cy.wait('#addCustomerMutation', { timeout: 60000 })
.its('request.body.variables')
.should('deep.equal', {
clientId: 'client_id',
customer: {
firstName: 'test',
lastName: 'tester',
email: 'test#test.com',
phone: {
name: '',
number: '(531) 731-3151',
},
alternatePhones: [],
},
});
How can I resolve this issue? So far I tried:
reverting cypress back to 6.4 and 6.8 per: https://github.com/cypress-io/cypress/issues/3427#issuecomment-462490501
added another assertion right after wait per: https://stackoverflow.com/a/71754497/9842672
increased timeout up to 100000
None of them worked. However, the local tests ran and passes with all these options as well.
My GitHub Actions workflow look like this if it helps:
jobs:
test:
concurrency: test # so that we don't run tests for another branch at the same time
runs-on: ubuntu-latest
container: cypress/browsers
steps:
- name: Checkout code
uses: actions/checkout#v3
- name: Setup npm token
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN_RO }}" >> ./.npmrc
- name: Setup node
uses: actions/setup-node#v3
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
cache: npm
- name: Npm install
run: npm ci
- name: Run tests
uses: cypress-io/github-action#v5
with:
env: username=${{ secrets.CYPRESS_TEST_USER }},password=${{ secrets.CYPRESS_TEST_PASSWORD }},REACT_APP_URI=${{ secrets.REACT_APP_URI }}
install-command: | # TODO: check node modules before you npm ci here
npm ci --production=false
browser: chrome
spec: cypress/integration/*.spec.*
start: npm run start:cypress
wait-on: npx wait-on http://localhost:3000
- name: Upload test screenshots
uses: actions/upload-artifact#v3
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots
# Test run video was always captured, so this action uses "always()" condition
- name: Upload test videos
uses: actions/upload-artifact#v3
if: always()
with:
name: cypress-videos
path: cypress/videos

Related

Trying to call a workflow in a private repo under same organization but getting error

We are trying to call a workflow from a private repo under our organization. Both repos are private repos under the same organization.
Organisation A --> private - repo-1 / .github\workflows\qatest.yml
Organisation A --> private - repo-2 / .github\workflows\test.yml
But while running we are getting error like :
Error details:
RequestError [HttpError]: Not Found
at /home/runner/work/_actions/actions/github-script/v6/dist/index.js:6172:21
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
status: 404
repository 'https://github.com/somebookingtest/e2e-cypress/' not found
Could someone please advise on how to fix this issue here ?
Below is the action from //repo2/ test.yml
name: end to end testing
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
first:
name: end to end testing
uses: somebookingtest/e2e-cypres/.github/workflows/maintest.yml#main-fixes
permissions: read-all
with:
environment: qastaging
tag: "#e2etests"
second:
runs-on: ubuntu-latest
steps:
- name: Trigger Workflow
uses: actions/github-script#v6
with:
script: |
github.rest.actions.createWorkflowDispatch({
owner: 'booking',
repo: 'e2e-cypres',
workflow_id: 'maintest.yml',
ref: 'main-fixes',
})
You have to use PAT - Personal Access Token instead of the default one - the default one only allows reading the active repository.
Create a personal access token
Add it to your secrets
add: github-token: ${{ secrets.MY_PAT }} to your second job as documented here
name: end to end testing
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
first:
name: end to end testing
uses: somebookingtest/e2e-cypres/.github/workflows/maintest.yml#main-fixes
permissions: read-all
with:
environment: qastaging
tag: "#e2etests"
second:
runs-on: ubuntu-latest
steps:
- name: Trigger Workflow
uses: actions/github-script#v6
with:
github-token: ${{ secrets.MY_PAT }}
script: |
github.rest.actions.createWorkflowDispatch({
owner: 'booking',
repo: 'e2e-cypres',
workflow_id: 'maintest.yml',
ref: 'main-fixes',
})

Tasks are not populated in concourse pipeline (Concourse version 7.8.2)

I am brand new to the concourse and trying to set up a pipeline through the pipeline but why am I getting this error on my very first pipeline, can anyone help out?
'''
jobs:
name: update-library-cache
serial: true
plan:
get: library_cache
get: infra
trigger: true
in_parallel:
{task: update-library-cache, file:infra/ci/tasks/update-preprod-library-cache.yml}
{put: library_cache, params: {file: updated_cache/infra-cache-*.tgz}}
name: build
serial: true
plan:
{get: api, trigger: true}
get: infra
get: library_cache
in_parallel:
-steps:
{task: js, file: infra/ci/tasks/build-service.yml, privileged: true, params: {TARGET_CFG: ((alpha)), SERVICE: js}, attempts:2}
{task: api, file: infra/ci/tasks/build-service.yml, privileged: true, params: {TARGET_CFG: ((alpha)), SERVICE: api}, attempts:2}
{task: worker, file: infra/ci/tasks/build-service.yml, privileged: true, params: {TARGET_CFG: ((alpha)), SERVICE: worker}, attempts:2}
When Executing pipeline:
the task: js , api and worker are not populating in the pipeline.
Is the syntax is correct for:
- in_parallel:
-steps:
- {task: js, file: infra/ci/tasks/build-service.yml, privileged: true, params: {TARGET_CFG: ((alpha)), SERVICE: js}, attempts:2}
- {task: api, file: infra/ci/tasks/build-service.yml, privileged: true, params: {TARGET_CFG: ((alpha)), SERVICE: api}, attempts:2}
- {task: worker, file: infra/ci/tasks/build-service.yml, privileged: true, params: {TARGET_CFG: ((alpha)), SERVICE: worker}, attempts:2}

Testcafe workflow for IE on Window on Github Actions: Error: The action has timed out

After a couple of regression in our app undre Internet Explorer (IE11), we decided to setup a dedicated CI workflow to prevent them anyfurther. So we went with testcafe, but the setup is more complicated than with Cypress.
Currently my tests are starting but they got stock
Package.json
"scripts": {
"start": "node scripts/start.js -- --deploy=local",
"test:ci:ie": "node ./node_modules/testcafe/bin/testcafe ie testcafe/ --app \"node scripts/start.js -- --deploy=local\" --app-init-delay 60000 --reporter spec-time"
}
Workflow using DevExpress/testcafe-action#latest
Noting fancy here
jobs:
test-e2e-ie11:
if: github.event.pull_request.draft == false
name: Run Tests for IE11
runs-on: windows-2019
steps:
- name: Checkout code
uses: actions/checkout#v2
- uses: actions/setup-node#v2
with:
node-version: "14"
cache: "yarn"
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache node_modules
id: yarn-cache
uses: actions/cache#v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: End-to-end testing
uses: DevExpress/testcafe-action#latest
timeout-minutes: 10
with:
skip-install: true
args: 'ie testcafe --app "node scripts/start.js --deploy=local" --app-init-delay 60000 --browser-init-timeout 60000'
env:
NODE_ENV: development
DEBUG: testcafe:*
Testcafe Step Log (using action)
2021-07-20T09:09:30.385Z testcafe:tested-app:stdout Compiled successfully!
2021-07-20T09:09:30.385Z testcafe:tested-app:stdout
You can now view web-bot in the browser.
Local: http://localhost:3000/
On Your Network: http://10.1.0.132:3000
Note that the development build is not optimized.
To create a production build, use yarn build.
Running tests in:
- Internet Explorer 11.0 / Windows 10
theme_04: conversation
2021-07-20T09:09:51.216Z testcafe:test-run:Internet Explorer 11.0 / Windows 10:driver-message
{
cmd: 'ready',
status: {
id: '1330.243',
isCommandResult: false,
executionError: null,
pageError: null,
resent: false,
result: null,
consoleMessages: {
null: [Object]
},
isPendingWindowSwitching: false,
isFirstRequestAfterWindowSwitching: false,
debug: ''
},
disableResending: true,
allowRejecting: true,
sessionId: 'dOloGSq4b'
}
2021-07-20T09:09:51.267Z testcafe:test-run:Internet Explorer 11.0 / Windows 10:command
AssertionCommand {
type: 'assertion',
assertionType: 'ok',
actual: ReExecutablePromise {
_then: [],
_fn: [Function (anonymous)],
_taskPromise: null
},
expected: undefined,
expected2: undefined,
message: null,
options: AssertionOptions {
timeout: undefined,
allowUnawaitedPromise: false
}
}
2021-07-20T09:09:51.271Z testcafe:test-run:Internet Explorer 11.0 / Windows 10:command
ExecuteSelectorCommand {
type: 'execute-selector',
instantiationCallsiteName: 'Selector',
fnCode: '(function(){\n' +
' var __f$=(function(){return document.querySelectorAll("#bot-frame");});;\n' +
' return function(){\n' +
' var args = __dependencies$.boundArgs || arguments;\n' +
" var selectorFilter = window['%testCafeSelectorFilter%'];\n" +
'\n' +
' var nodes = __f$.apply(this, args);\n' +
' nodes = selectorFilter.cast(nodes);\n' +
'\n' +
' if (!nodes.length && !selectorFilter.error)\n' +
' selectorFilter.error = __dependencies$.apiInfo.apiFnID;\n' +
'\n' +
' return selectorFilter.filter(nodes, __dependencies$.filterOptions, __dependencies$.apiInfo);\n' +
' };\n' +
'})();',
args: [
[]
],
dependencies: [
[Object: null prototype] {
filterOptions: [Object: null prototype],
apiInfo: [Object: null prototype],
boundArgs: [Object: null prototype],
customDOMProperties: [Object: null prototype],
customMethods: [Object: null prototype]
}
],
visibilityCheck: true,
timeout: null,
apiFnChain: [
"Selector('#bot-frame')"
],
index: 0
}
Error: The action has timed out.
Workflow using run with npm command
The last command is different, see the log.
- name: End-to-end testing
run: npm run test:ci:ie
timeout-minutes: 10
env:
NODE_ENV: development
DEBUG: testcafe:*
Testcafe Step Log (using run)
2021-07-20T09:24:57.703Z testcafe:test-run:Internet Explorer 11.0 / Windows 10:driver-message
{
cmd: 'ready',
status: {
id: '4626.4743',
isCommandResult: false,
executionError: null,
pageError: null,
resent: false,
result: null,
consoleMessages: {
null: [Object]
},
isPendingWindowSwitching: false,
isFirstRequestAfterWindowSwitching: false,
debug: ''
},
disableResending: true,
allowRejecting: true,
sessionId: 'ZA8TILRDy'
}
Terminate batch job (Y/N)?
Error: The action has timed out.

Serverless Offline: The "path" argument must be of type string. Received undefined

Not sure why this started happening but I have a very simple serverless app that was working, but now when I run sls offline start I get the error above. I have found the culprit and it is the events inside the functions.
Here is the serverless.yml file:
service: hello-world-offline
provider:
name: aws
runtime: nodejs12.x
region: eu-east-1
stage: dev
plugins:
- serverless-offline
functions:
hello-world:
handler: handler.handle # required, handler set in AWS Lambda
events:
- http:
path: hello-world
method: get
cors: true
Here is the handler.js file:
module.exports.handle = async (event, ctx, cb) => {
cb(null, {
statusCode: 200,
body: JSON.stringify({ message: "hello world" })
})
}
If I get rid of the events in the function hello-world everything works just fine with sls offline start except for the fact I can't actually hit the endpoint locally of course. I've tried making it a hard string by adding quotes but that did nothing.
EDIT: Turns out this happens when using yarn workspaces. If I put this in a packages/my-serverless-app structure and cd into the folder to run the sls offline start command this happens. If I remove it from the structure it works just fine.
Change
events:
- http:
path: hello-world
method: get
cors: true
TO
events:
- httpApi:
path: hello-world
method: get
And this should work!

Jenkins JNLP slave is stuck on progress bar when need to run Maven job

I have a problem with my Jenkins which runs on K8s.
My Pipeline is built with 2 pods - Jnlp alpine (default for k8s) and Maven (3.6.0 based on java-8:jdk-8u191-slim image).
From time to time, after staring a new build it's getting stuck with no progress with the Build.
Entering the Pod:
Jnlp - seems to be functioning as expected
Maven - no job is running (running ps -ef).
Appreciate your help.
Tried to pause / resume - not solve it.
The only way is abort and reinitiate the build.
Jenkins version - 2.164.1
My pipeline is :
properties([[$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false],
parameters([string(defaultValue: 'master', description: '', name: 'branch', trim: false),
string(description: 'enter your namespace name', name: 'namespace', trim: false),])])
def label = "jenkins-slave-${UUID.randomUUID().toString()}"
podTemplate(label: label, namespace: "${params.namespace}", yaml: """
apiVersion: v1
kind: Pod
spec:
nodeSelector:
group: maven-ig
containers:
- name: maven
image: accontid.dkr.ecr.us-west-2.amazonaws.com/base_images:maven-base
command: ['cat']
resources:
limits:
memory: "16Gi"
cpu: "16"
requests:
memory: "10Gi"
cpu: "10"
tty: true
env:
- name: ENVIRONMENT
value: dev
- name: config.env
value: k8s
- mountPath: "/local"
name: nvme
volumes:
- name: docker
hostPath:
path: /var/run/docker.sock
- name: nvme
hostPath:
path: /local
"""
) {
node(label) {
wrap([$class: 'TimestamperBuildWrapper']) {
checkout([$class: 'GitSCM', branches: [[name: "*/${params.branch}"]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'credetials', url: 'https://github.com/example/example.git']]])
wrap([$class: 'BuildUser']) {
user = env.BUILD_USER_ID
}
currentBuild.description = 'Branch: ' + "${branch}" + ' | Namespace: ' + "${user}"
stage('Stable tests') {
container('maven') {
try {
sh "find . -type f -name '*k8s.*ml' | xargs sed -i -e 's|//mysql|//mysql.${user}.svc.cluster.local|g'"
sh "mvn -f pom.xml -Dconfig.env=k8s -Dwith_stripe_stub=true -Dpolicylifecycle.integ.test.url=http://testlifecycleservice-${user}.testme.io -Dmaven.test.failure.ignore=false -Dskip.surefire.tests=true -Dmaven.test.skip=false -Dskip.package.for.deployment=true -T 1C clean verify -fn -P stg-stable-it"
}
finally {
archive "**/target/failsafe-reports/*.xml"
junit '**/target/failsafe-reports/*.xml'
}
}
}
// stage ('Delete namespace') {
// build job: 'delete-namspace', parameters: [
// [$class: 'StringParameterValue', name: 'namespace', value: "${user}"]], wait: false
// }
}
}
}

Resources