When we run cypress in parallel, [email protected] and above receives service error during Uploading Results.
Cypress dashboard will be pending and never finish.
See the below error messages:
(Uploading Results)
We encountered an unexpected error talking to our servers.
Because you passed the --parallel flag, this run cannot proceed because it requires a valid response from our servers.
The --ciBuildId flag you passed was: xxx
The server's response was:
StatusCodeError: 412
{
"message": "Request should follow [email protected] schema",
"errors": [
"data.hooks.1.hookId is required",
"data.hooks.1.hookName is required"
],
"object": {
"stats": {
"suites": 8,
"tests": 16,
"passes": 16,
"pending": 0,
"skipped": 0,
"failures": 0,
"wallClockStartedAt": "2020-08-14T20:33:38.948Z",
"wallClockEndedAt": "2020-08-14T20:34:28.554Z",
"wallClockDuration": 49606
},
"tests": [
{
"testId": "r4",
"title": [
"Generic Landing Page",
"Landing Page Components",
"Should be present on load"
],
"state": "passed",
Tested different cypress versions includes 4.9.0, 4.10.0 and 4.12.1. 4.9.0 works fine without issues.
Looking at the change log https://github.com/cypress-io/cypress/releases/tag/v4.10.0
It includes hooks updates. That might cause the server error issue.
We have downgrade cypress from the latest version to 4.9.0 to run tests with cypress server.
cypress run --headless --browser chrome --record --key=<key> --ci-build-id=<build_id> --parallel --config baseUrl=<url>
4.10.0 and above
@char1e5 Can you provide the full error log? It looks like it may be cutting off beyond the beginning of the tests array.
There's likely a situation where the tests can run and incorrectly create a hook, which has no hookId or hookName. Is it possible to send over an example of the test you're running - specifically around the structure of the hooks/suite/tests? This would help us recreate the situation where this would happen. Feel free to send anything over to [email protected].
I am having this issue with running any version of Cypress. I tried 2.0.0 3.0.0 and all versions of 4.x.x
Warning: We encountered an error talking to our servers.
This run will not be recorded.
This error will not alter the exit code.
StatusCodeError: 412
{
"message": "Request should follow [email protected] schema",
"errors": [
"data.hooks.2.hookId is required",
"data.hooks.2.hookName is required"
],
"object": {
"stats": {
"suites": 1,
"tests": 4,
"passes": 4,
"pending": 0,
"skipped": 0,
"failures": 0,
"wallClockStartedAt": "2020-08-21T20:44:48.243Z",
"wallClockEndedAt": "2020-08-21T20:45:05.793Z",
"wallClockDuration": 17550
},
"tests": [
{
"testId": "r3",
"title": [
"/account/info > Accounts info",
"should reset account name before other tests"
],
"state": "passed",
"body": "function () {\n if (Cypress.env('configFile' !== 'local')) {\n cy.get(account_selectors_json_1.default.alert).click();\n }\n // Rename account to ensure it starts the same way every time\n cy.visit('/account/info');\n cy.get(account_selectors_json_1.default.renameAccountBtn).click();\n cy.get(account_selectors_json_1.default.renameAccount).clear().type('No Loan');\n cy.get(account_selectors_json_1.default.updateAccountName).click();\n cy.get(account_selectors_json_1.default.nameValue).then(function ($acnt) {\n accountName = $acnt.text();\n cy.get(account_selectors_json_1.default.accountDropdown).contains(accountName);\n });\n }",
"stack": null,
"error": null,
"timings": {
"lifecycle": 59,
"before all": [
{
"hookId": "h2",
"fnDuration": 4917,
"afterFnDuration": 1
}
],
"before each": [
{
"hookId": "h1",
"fnDuration": 4,
"afterFnDuration": 0
},
{
"fnDuration": 1,
"afterFnDuration": 0
}
],
"test": {
"fnDuration": 4225,
"afterFnDuration": 0
}
},
"failedFromHookId": null,
"wallClockStartedAt": "2020-08-21T20:44:48.275Z",
"wallClockDuration": 9293,
"videoTimestamp": 21305
},
{
"testId": "r4",
"title": [
"/account/info > Accounts info",
"should cancel renaming account"
],
"state": "passed",
"body": "function () {\n cy.visit('/account/info');\n cy.get(account_selectors_json_1.default.renameAccountBtn).click();\n cy.get(account_selectors_json_1.default.cancel).click();\n cy.get(account_selectors_json_1.default.accountDropdown).contains(accountName);\n }",
"stack": null,
"error": null,
"timings": {
"lifecycle": 49,
"before each": [
{
"hookId": "h1",
"fnDuration": 2,
"afterFnDuration": 0
},
{
"fnDuration": 1,
"afterFnDuration": 0
}
],
"test": {
"fnDuration": 2200,
"afterFnDuration": 1
}
},
"failedFromHookId": null,
"wallClockStartedAt": "2020-08-21T20:44:57.576Z",
"wallClockDuration": 2267,
"videoTimestamp": 30606
},
{
"testId": "r5",
"title": [
"/account/info > Accounts info",
"should throw error for invalid characters"
],
"state": "passed",
"body": "function () {\n cy.visit('/account/info');\n cy.get(account_selectors_json_1.default.renameAccountBtn).click();\n cy.get(account_selectors_json_1.default.renameAccount)\n .clear()\n .type(accountName + '-updated!');\n cy.get(account_selectors_json_1.default.updateAccountName).click();\n cy.get(account_selectors_json_1.default.updateError).should('be.visible');\n cy.get(account_selectors_json_1.default.cancel).click();\n cy.get(account_selectors_json_1.default.accountDropdown).contains(accountName);\n }",
"stack": null,
"error": null,
"timings": {
"lifecycle": 47,
"before each": [
{
"hookId": "h1",
"fnDuration": 2,
"afterFnDuration": 0
},
{
"fnDuration": 1,
"afterFnDuration": 0
}
],
"test": {
"fnDuration": 2822,
"afterFnDuration": 0
}
},
"failedFromHookId": null,
"wallClockStartedAt": "2020-08-21T20:44:59.847Z",
"wallClockDuration": 2912,
"videoTimestamp": 32877
},
{
"testId": "r6",
"title": [
"/account/info > Accounts info",
"should rename account"
],
"state": "passed",
"body": "function () {\n cy.visit('/account/info');\n cy.get(account_selectors_json_1.default.renameAccountBtn).click();\n cy.get(account_selectors_json_1.default.renameAccount)\n .clear()\n .type(accountName + '-updated1');\n cy.get(account_selectors_json_1.default.updateAccountName).click();\n cy.get(account_selectors_json_1.default.nameValue).contains(accountName + '-updated1');\n }",
"stack": null,
"error": null,
"timings": {
"lifecycle": 32,
"before each": [
{
"hookId": "h1",
"fnDuration": 1,
"afterFnDuration": 0
},
{
"fnDuration": 1,
"afterFnDuration": 0
}
],
"test": {
"fnDuration": 2961,
"afterFnDuration": 0
}
},
"failedFromHookId": null,
"wallClockStartedAt": "2020-08-21T20:45:02.766Z",
"wallClockDuration": 3019,
"videoTimestamp": 35796
}
],
"error": null,
"video": true,
"hooks": [
{
"hookId": "h2",
"hookName": "before all",
"title": [
"\"before all\" hook: login"
],
"body": "function () {\n cy.setLoginCookies({\n account: 'cypress-noloan-personal',\n url: '/account/info',\n });\n beforeEach('preserveLogin', function () {\n cy.preserveLogin();\n });\n }"
},
{
"hookId": "h1",
"hookName": "before each",
"title": [
"\"before each\" hook: All"
],
"body": "function () {\n cy.server();\n cy.route({\n method: 'GET',\n url: '/images/lottie/**',\n status: 400,\n response: {},\n delay: 0,\n });\n}"
},
{
"title": [
"\"before each\" hook: preserveLogin"
],
"body": "function () {\n cy.preserveLogin();\n }"
}
],
"stdout": null,
"screenshots": [],
"cypressConfig": {
"baseUrl": "https://borrower-portal.dev.saltlending.tech",
"bpApi": "https://borrower-portal.dev.saltlending.tech/api/v0",
"env": {
"BASE_BP_API": "https://borrower-portal.dev.saltlending.tech/api/v0",
"FIXTURE_ENV": "dev",
"AWS": "{\n \"userPoolWebClientId\": \"xxxxxx\",\n \"region\": \"us-west-2\",\n \"userPoolId\": \"us-west-xxxx\"\n}\n",
"configFile": ""
},
"viewportWidth": 2000,
"viewportHeight": 1500,
"projectId": "vwet7n",
"chromeWebSecurity": false,
"waitForAnimations": true,
"blacklistHosts": [
"*doubleclick.net*",
"*adservice.google.com*",
"*google-analytics.com*",
"*googletagmanager*",
"*facebook.com*"
],
"watchForFileChanges": false,
"ignoreTestFiles": [
"*.json",
"*.types.js"
],
"defaultCommandTimeout": 15000,
"pageLoadTimeout": 25000,
"responseTimeout": 10000,
"requestTimeout": 30000,
"projectRoot": "/Users/sshirley/Documents/GitHub/borrower-portal/e2e",
"projectName": "e2e",
"morgan": false,
"isTextTerminal": true,
"socketId": "h6scl",
"report": true,
"browsers": [
{
"name": "chrome",
"family": "chromium",
"channel": "stable",
"displayName": "Chrome",
"version": "84.0.4147.135",
"path": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
"majorVersion": 84
},
{
"name": "electron",
"channel": "stable",
"family": "chromium",
"displayName": "Electron",
"version": "80.0.3987.165",
"path": "",
"majorVersion": 80,
"info": "Electron is the default browser that comes with Cypress. This is the default browser that runs in headless mode. Selecting this browser is useful when debugging. The version number indicates the underlying Chromium version that Electron uses."
}
],
"port": 64163,
"hosts": null,
"userAgent": null,
"reporter": "spec",
"reporterOptions": null,
"clientRoute": "/__/",
"xhrRoute": "/xhrs/",
"socketIoRoute": "/__socket.io",
"socketIoCookie": "__socket.io",
"reporterRoute": "/__cypress/reporter",
"testFiles": "**/*.*",
"execTimeout": 60000,
"taskTimeout": 60000,
"video": true,
"videoCompression": 32,
"videoUploadOnPasses": true,
"screenshotOnRunFailure": true,
"modifyObstructiveCode": true,
"animationDistanceThreshold": 5,
"numTestsKeptInMemory": 0,
"trashAssetsBeforeRuns": true,
"autoOpen": false,
"fileServerFolder": "/Users/sshirley/Documents/GitHub/borrower-portal/e2e",
"videosFolder": "/Users/sshirley/Documents/GitHub/borrower-portal/e2e/cypress/videos",
"supportFile": "/Users/sshirley/Documents/GitHub/borrower-portal/e2e/cypress/support/index.js",
"fixturesFolder": "/Users/sshirley/Documents/GitHub/borrower-portal/e2e/cypress/fixtures",
"integrationFolder": "/Users/sshirley/Documents/GitHub/borrower-portal/e2e/cypress/integration",
"screenshotsFolder": "/Users/sshirley/Documents/GitHub/borrower-portal/e2e/cypress/screenshots",
"namespace": "__cypress",
"pluginsFile": "/Users/sshirley/Documents/GitHub/borrower-portal/e2e/cypress/plugins/index.js",
"nodeVersion": "default",
"configFile": "cypress.json",
"firefoxGcInterval": {
"runMode": 1,
"openMode": null
},
"javascripts": [],
"experimentalComponentTesting": false,
"componentFolder": "/Users/sshirley/Documents/GitHub/borrower-portal/e2e/cypress/component",
"experimentalGetCookiesSameSite": false,
"experimentalSourceRewriting": false,
"experimentalShadowDomSupport": false,
"experimentalFetchPolyfill": false,
"cypressEnv": "production",
"resolved": {
"animationDistanceThreshold": {
"value": 5,
"from": "default"
},
"fileServerFolder": {
"value": "",
"from": "default"
},
"baseUrl": {
"value": "https://borrower-portal.dev.saltlending.tech",
"from": "plugin"
},
"fixturesFolder": {
"value": "cypress/fixtures",
"from": "default"
},
"blacklistHosts": {
"value": [
"*doubleclick.net*",
"*adservice.google.com*",
"*google-analytics.com*",
"*googletagmanager*",
"*facebook.com*"
],
"from": "config"
},
"chromeWebSecurity": {
"value": false,
"from": "config"
},
"modifyObstructiveCode": {
"value": true,
"from": "default"
},
"integrationFolder": {
"value": "cypress/integration",
"from": "default"
},
"env": {
"configFile": {
"value": "",
"from": "cli"
},
"BASE_BP_API": {
"value": "https://borrower-portal.dev.saltlending.tech/api/v0",
"from": "plugin"
},
"FIXTURE_ENV": {
"value": "dev",
"from": "plugin"
},
"AWS": {
"value": "{\n \"userPoolWebClientId\": \"297qjog9ouuajoengo70pkbenv\",\n \"region\": \"us-west-2\",\n \"userPoolId\": \"us-west-2_h1QwUapUI\"\n}\n",
"from": "plugin"
}
},
"pluginsFile": {
"value": "cypress/plugins",
"from": "default"
},
"hosts": {
"value": null,
"from": "default"
},
"screenshotsFolder": {
"value": "cypress/screenshots",
"from": "default"
},
"numTestsKeptInMemory": {
"value": 0,
"from": "config"
},
"supportFile": {
"value": "cypress/support",
"from": "default"
},
"port": {
"value": null,
"from": "default"
},
"projectId": {
"value": "vwet7n",
"from": "config"
},
"videosFolder": {
"value": "cypress/videos",
"from": "default"
},
"reporter": {
"value": "spec",
"from": "default"
},
"reporterOptions": {
"value": null,
"from": "default"
},
"ignoreTestFiles": {
"value": [
"*.json",
"*.types.js"
],
"from": "config"
},
"testFiles": {
"value": "**/*.*",
"from": "default"
},
"defaultCommandTimeout": {
"value": 15000,
"from": "config"
},
"trashAssetsBeforeRuns": {
"value": true,
"from": "default"
},
"execTimeout": {
"value": 60000,
"from": "default"
},
"userAgent": {
"value": null,
"from": "default"
},
"pageLoadTimeout": {
"value": 25000,
"from": "config"
},
"viewportWidth": {
"value": 2000,
"from": "config"
},
"requestTimeout": {
"value": 30000,
"from": "config"
},
"viewportHeight": {
"value": 1500,
"from": "config"
},
"responseTimeout": {
"value": 10000,
"from": "config"
},
"video": {
"value": true,
"from": "default"
},
"taskTimeout": {
"value": 60000,
"from": "default"
},
"videoCompression": {
"value": 32,
"from": "default"
},
"videoUploadOnPasses": {
"value": true,
"from": "default"
},
"screenshotOnRunFailure": {
"value": true,
"from": "default"
},
"watchForFileChanges": {
"value": false,
"from": "config"
},
"waitForAnimations": {
"value": true,
"from": "default"
},
"nodeVersion": {
"value": "default",
"from": "default"
},
"firefoxGcInterval": {
"value": {
"runMode": 1,
"openMode": null
},
"from": "default"
},
"componentFolder": {
"value": "cypress/component",
"from": "default"
},
"browsers": {
"value": [
{
"name": "chrome",
"family": "chromium",
"channel": "stable",
"displayName": "Chrome",
"version": "84.0.4147.135",
"path": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
"majorVersion": 84
},
{
"name": "electron",
"channel": "stable",
"family": "chromium",
"displayName": "Electron",
"version": "80.0.3987.165",
"path": "",
"majorVersion": 80,
"info": "Electron is the default browser that comes with Cypress. This is the default browser that runs in headless mode. Selecting this browser is useful when debugging. The version number indicates the underlying Chromium version that Electron uses.",
"isHeadless": true,
"isHeaded": false
}
],
"from": "default"
},
"experimentalGetCookiesSameSite": {
"value": false,
"from": "default"
},
"experimentalSourceRewriting": {
"value": false,
"from": "default"
},
"experimentalComponentTesting": {
"value": false,
"from": "default"
},
"experimentalShadowDomSupport": {
"value": false,
"from": "default"
},
"experimentalFetchPolyfill": {
"value": false,
"from": "default"
},
"bpApi": {
"value": "https://borrower-portal.dev.saltlending.tech/api/v0",
"from": "plugin"
}
},
"parentTestsFolder": "/Users/sshirley/Documents/GitHub/borrower-portal/e2e/cypress",
"parentTestsFolderDisplay": "e2e/cypress",
"supportFolder": "/Users/sshirley/Documents/GitHub/borrower-portal/e2e/cypress/support",
"integrationExampleName": "examples",
"integrationExamplePath": "/Users/sshirley/Documents/GitHub/borrower-portal/e2e/cypress/integration/examples",
"scaffoldedFiles": [
{
"name": "cypress",
"children": [
{
"name": "integration",
"children": [
{
"name": "examples",
"children": [
{
"name": "actions.spec.js"
},
{
"name": "aliasing.spec.js"
},
{
"name": "assertions.spec.js"
},
{
"name": "connectors.spec.js"
},
{
"name": "cookies.spec.js"
},
{
"name": "cypress_api.spec.js"
},
{
"name": "files.spec.js"
},
{
"name": "local_storage.spec.js"
},
{
"name": "location.spec.js"
},
{
"name": "misc.spec.js"
},
{
"name": "navigation.spec.js"
},
{
"name": "network_requests.spec.js"
},
{
"name": "querying.spec.js"
},
{
"name": "spies_stubs_clocks.spec.js"
},
{
"name": "traversal.spec.js"
},
{
"name": "utilities.spec.js"
},
{
"name": "viewport.spec.js"
},
{
"name": "waiting.spec.js"
},
{
"name": "window.spec.js"
}
]
}
]
},
{
"name": "fixtures",
"children": [
{
"name": "example.json"
}
]
},
{
"name": "support",
"children": [
{
"name": "commands.js"
},
{
"name": "index.js"
}
]
},
{
"name": "plugins",
"children": [
{
"name": "index.js"
}
]
}
]
}
],
"resolvedNodeVersion": "12.13.0",
"state": {},
"proxyUrl": "http://localhost:64163",
"browserUrl": "https://borrower-portal.dev.saltlending.tech/__/",
"reporterUrl": "https://borrower-portal.dev.saltlending.tech/__cypress/reporter",
"xhrUrl": "__cypress/xhrs/"
},
"reporterStats": {
"suites": 1,
"tests": 4,
"passes": 4,
"pending": 0,
"failures": 0,
"start": "2020-08-21T20:44:48.252Z",
"end": "2020-08-21T20:45:05.807Z",
"duration": 17555
}
},
"schemaName": "PutInstanceRequest",
"schemaVersion": "2.1.0"
}
Hey @char1e5 and @samuelshirley, we have some reason to believe that you may have written some of the tests with hooks nested within hooks, so something like below (or any other defined hook):
beforeEach(() => {
afterEach(() => {})
})
Can either of you confirm that there are nested hooks within your test suite somewhere?
We are still discussing how we want to handle nested hooks in the future (we may error when they are defined altogether)
For now, we recommend that all hooks be defined separately. This change would not change how the hooks execute.
@jennifer-shehane searching for our code, we do have nested hooks in our tests. But I think that's a valid case we had earlier. We need to define some common hooks to run it before all tests. If we separate the hooks, it's not ideal for us to manage our tests.
Any recommendation in that case?
@char1e5 If you want common hooks, you can place them in a support file. Could you give an example where a nested hook is required?
@Bkucera yes, we have 2 places having nested hooks in our tests.
nested hooks earlier. But it's really just one common hooks with nested before, which is incorrect code in my opinion. It has before(() => (before(() => {}))). beforeEach(() => (beforeEach(() => {}))). We can change fix it, too.Thanks to point this out about nested hooks. I'd like to have some cypress alerts or even support nested hooks in the future. It's really hard us to tell what's wrong from the error message.
At the same time, I can update the code and see how it works in the new version of cypress.
@jennifer-shehane I suggest erroring, there should be no case where you want to nest hooks that cannot be simplified into flat hooks. Plus it's super confusing to maintain those kinds of tests.
erroring on nested hooks is implemented in #8400
The code for this is done in cypress-io/cypress#8400, but has yet to be released.
We'll update this issue and reference the changelog when it's released.
Released in 5.1.0.
This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v5.1.0, please open a new issue.
Most helpful comment
erroring on nested hooks is implemented in #8400