Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make ScriptError display at full height in Runner #21653

Merged
merged 9 commits into from
May 31, 2022
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>