nuxt / create-nuxt-app

Create Nuxt.js App in seconds.
MIT License
3.48k stars 429 forks source link

AVA e2e Test Fails on Fresh Creation/Install #846

Open aphix opened 3 years ago

aphix commented 3 years ago

Using create-nuxt-app v3.7.1

Super simple fix, just seems like it may have been overlooked, the e2e tests are expecting the result HTML to contain "Documentation" but it does not, so the tests will fail on a fresh CNA install.

Cause

I believe this was the only place where an title-cased "Documentation" (with uppercase "D") previously existed on the page, and it has since been removed (all current usages are lower-cased, I believe this is the removal commit): https://github.com/nuxt/create-nuxt-app/pull/792/files#diff-7aff5013bd918f32408501b682a5e2bd6dbc475ee1c509efb525f6803ea3ee03L15 (packages/cna-template/template/nuxt/pages/index.vue on removed line 15 in that commit, the line should be linked)

Fix

Change this line: https://github.com/nuxt/create-nuxt-app/blob/master/packages/cna-template/template/frameworks/ava/test/e2e/index.spec.js#L24

Make the "D" lowercase, e.g. replace t.true(html.includes('Documentation')) with t.true(html.includes('documentation'))

Alternatively use a case-insensitive regex, or even better just check the status code rather than making it dependent on the actual content of the page, to prevent content changes from breaking the test in the future.

CNA Settings

Programming language: JavaScript
Package manager: Npm
UI framework: None
Nuxt.js modules: Axios - Promise based HTTP client, Progressive Web App (PWA)
Linting tools: ESLint
Testing framework: AVA
Rendering mode: Universal (SSR / SSG)
Deployment target: Server (Node.js hosting)
Development tools: jsconfig.json (Recommended for VS Code if you're not using typescript)
Continuous integration: None
Version control system: Git

Failure Output (after npm run test):

# before hook
not ok 1 - Route / exits and render HTML
  ---
    name: AssertionError
    assertion: 'true'
    values:
      'Value is not `true`:': 'false'
    at: 'test/e2e/index.spec.js:29:3'
  ...

1..1
# tests 1
# pass 0
# fail 1

P.S. I don't believe it's related, and it's possibly working as intended, but the line numbers are incorrect in the AVA test failure output (t.true(html.includes('Documentation')) is not on line 29). I'm investigating that now and will create another ticket if needed.

Thanks, Aphix