Skip to content

Commit

Permalink
fix: remove asset size warnings and enable nuxt e2e tests (#21074)
Browse files Browse the repository at this point in the history
* fix: remove asset size warnings and enable nuxt e2e tests

* bump timeout
  • Loading branch information
ZachJW34 authored Apr 14, 2022
1 parent 0e7b555 commit 6dae45e
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 8 deletions.
2 changes: 1 addition & 1 deletion npm/webpack-dev-server-fresh/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from 'cypress'
export default defineConfig({
projectId: 'ypt4pf',
e2e: {
defaultCommandTimeout: 10000, // these take a bit longer b/c they're e2e open mode test
defaultCommandTimeout: 20000, // these take a bit longer b/c they're e2e open mode test
async setupNodeEvents (on, config) {
if (!process.env.HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS) {
throw new Error('HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS is missing. Close Cypress and run tests using the `yarn cypress:*` commands from the `packages/app` directory')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ for (const project of WEBPACK_REACT) {
)
})

cy.get('.failed > .num', { timeout: 10000 }).should('contain', 1)
cy.get('.failed > .num').should('contain', 1)

cy.withCtx(async (ctx) => {
await ctx.actions.file.writeFileInProject(
Expand Down
45 changes: 42 additions & 3 deletions npm/webpack-dev-server-fresh/cypress/e2e/nuxt.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// <reference path="../support/e2e.ts" />
import type { ProjectFixtureDir } from '@tooling/system-tests/lib/fixtureDirs'

const PROJECTS: ProjectFixtureDir[] = ['nuxtjs2', 'vuecli4-vue2']
const PROJECTS: ProjectFixtureDir[] = ['nuxtjs2']

// Add to this list to focus on a particular permutation
const ONLY_PROJECTS: ProjectFixtureDir[] = []
Expand All @@ -14,17 +14,56 @@ for (const project of PROJECTS) {

// TODO: This will work once `cypress/vue2` is bundled in the binary
// Since Nuxt.js 2 is based on `vue@2`.
describe.skip(`Working with ${project}`, () => {
describe(`Working with ${project}`, () => {
beforeEach(() => {
cy.scaffoldProject(project)
cy.openProject(project)
cy.startAppServer('component')
})

it('should mount a passing test', () => {
it('should mount a passing test and live-reload', () => {
cy.visitApp()
cy.contains('Tutorial.cy.js').click()
cy.get('.passed > .num').should('contain', 1)

cy.withCtx(async (ctx) => {
const tutorialVuePath = ctx.path.join('components', 'Tutorial.vue')

await ctx.actions.file.writeFileInProject(
tutorialVuePath,
(await ctx.file.readFileInProject(tutorialVuePath)).replace('Nuxt', 'Tutorial'),
)
})

cy.get('.failed > .num').should('contain', 1)

cy.withCtx(async (ctx) => {
const tutorialCyPath = ctx.path.join('components', 'Tutorial.cy.js')

await ctx.actions.file.writeFileInProject(
tutorialCyPath,
(await ctx.file.readFileInProject(tutorialCyPath)).replace('Nuxt', 'Tutorial'),
)
})

cy.get('.passed > .num').should('contain', 1)
})

it('should detect new spec', () => {
cy.visitApp()

cy.withCtx(async (ctx) => {
const newSpecPath = ctx.path.join('components', 'New.cy.js')
const tutorialCyPath = ctx.path.join('components', 'Tutorial.cy.js')

await ctx.actions.file.writeFileInProject(
newSpecPath,
await ctx.file.readFileInProject(tutorialCyPath),
)
})

cy.contains('New.cy.js').click()
cy.get('.passed > .num').should('contain', 1)
})
})
}
4 changes: 4 additions & 0 deletions npm/webpack-dev-server-fresh/src/helpers/nuxtHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export async function nuxtHandler ({ devServerConfig }: PresetHandler): Promise<

const webpackConfig = await getWebpackConfig()

// Nuxt has asset size warnings configured by default which will cause webpack overlays to appear
// in the browser which we don't want.
delete webpackConfig.performance

debug('webpack config %o', webpackConfig)

return webpackConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ describe('nuxtHandler', function () {

// Verify it's a Vue-specific webpack config by seeing if VueLoader is present.
expect(config.plugins.find((plug) => plug.constructor.name === 'VueLoader'))
expect(config.performance).to.be.undefined
})
})
14 changes: 11 additions & 3 deletions system-tests/project-fixtures/nuxtjs2/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ export default defineConfig({
component: {
devServer: {
framework: 'nuxt',
bundler: 'webpack'
}
bundler: 'webpack',
// Necessary due to cypress/vue resolving from cypress/node_modules rather than the project root
webpackConfig: {
resolve: {
alias: {
'vue': require.resolve('vue'),
}
}
}
},
},
})
})

2 comments on commit 6dae45e

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6dae45e Apr 14, 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/10.0-release-6dae45e8dba901e8499c1a532797dc48d337631a/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6dae45e Apr 14, 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/10.0-release-6dae45e8dba901e8499c1a532797dc48d337631a/cypress.tgz

Please sign in to comment.