Skip to content

Commit

Permalink
Merge pull request #21653 from cypress-io/marktnoonan/script-error-he…
Browse files Browse the repository at this point in the history
…ight

fix: make ScriptError display at full height in Runner
  • Loading branch information
mjhenkes authored May 31, 2022
2 parents 292f8b4 + c301f8e commit a937e4c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
28 changes: 28 additions & 0 deletions packages/app/cypress/e2e/cypress-in-cypress-e2e.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,34 @@ describe('Cypress In Cypress E2E', { viewportWidth: 1500, defaultCommandTimeout:
cy.get('[data-model-state="passed"]').should('contain', 'renders the blank page')
})

it('shows a compilation error with a malformed spec', { viewportHeight: 596, viewportWidth: 1000 }, () => {
const expectedAutHeight = 500 // based on explicitly setting viewport in this test to 596

cy.visitApp()

cy.withCtx(async (ctx, o) => {
await ctx.actions.file.writeFileInProject(o.path, `describe('Bad spec', () => { it('has a syntax error', () => { expect(true).to.be.true }) }`)
}, { path: getPathForPlatform('cypress/e2e/bad-spec.spec.js') })

cy.contains('bad-spec.spec')
.click()

cy.contains('No tests found').should('be.visible')

cy.contains('SyntaxError')
.should('be.visible')
.invoke('outerHeight')
.should('eq', expectedAutHeight)

// Checking the height here might seem excessive
// but we really want some warning if this changes
// and should understand the reasons if it does.
// We could consider removing this after percy is
// up and running for e2e tests.

cy.percySnapshot()
})

it('should show visit failure blank page', () => {
cy.visitApp()
cy.contains('blank-contents.spec')
Expand Down
6 changes: 5 additions & 1 deletion packages/app/src/runner/ScriptError.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<template>
<pre
class="text-red-500 bg-white p-24px overflow-auto h-[calc(100%-70px)] whitespace-pre-wrap break-all text-sm"
class="bg-white text-sm p-24px text-red-500 overflow-auto whitespace-pre-wrap break-all"
:style="style"
v-html="scriptError"
/>
</template>

<script setup lang="ts">
import ansiToHtml from 'ansi-to-html'
import { computed } from 'vue'
import { useAutStore } from '../store'
const autStore = useAutStore()
const convert = new ansiToHtml({
fg: '#000',
bg: '#fff',
Expand All @@ -20,5 +23,6 @@ const convert = new ansiToHtml({
const props = defineProps<{ error: string }>()
const scriptError = computed(() => convert.toHtml(props.error))
const style = computed(() => `height: calc(100vh - ${autStore.specRunnerHeaderHeight + 32}px)`)
</script>

3 comments on commit a937e4c

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on a937e4c May 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.0.0/linux-x64/develop-a937e4ce240b61f2f566acc7195d5b9a4be2ed8a/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on a937e4c May 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.0.0/darwin-x64/develop-a937e4ce240b61f2f566acc7195d5b9a4be2ed8a/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on a937e4c May 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.0.0/win32-x64/develop-a937e4ce240b61f2f566acc7195d5b9a4be2ed8a/cypress.tgz

Please sign in to comment.