All Projects → alidlorenzo → Nuxt Jest Puppeteer

alidlorenzo / Nuxt Jest Puppeteer

Licence: mit
🚀 Nuxt.js zero configuration tests, run with Jest and Puppetter

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Nuxt Jest Puppeteer

zero
📦 A zero config scripts library
Stars: ✭ 17 (-70.18%)
Mutual labels:  jest, zero-configuration
Marvelheroes
Marvel Heroes
Stars: ✭ 54 (-5.26%)
Mutual labels:  jest, puppeteer
xstate-marionettist
Model based testing with Jest, XState and Puppeteer or Playwright made easy
Stars: ✭ 23 (-59.65%)
Mutual labels:  jest, puppeteer
Puppeteer Examples
Puppeteer example scripts for running Headless Chrome from Node.
Stars: ✭ 2,781 (+4778.95%)
Mutual labels:  jest, puppeteer
Jest Puppeteer
Run your tests using Jest & Puppeteer 🎪✨
Stars: ✭ 3,267 (+5631.58%)
Mutual labels:  jest, puppeteer
Buefy Shop
A sample shop built with Nuxt, Stripe, Firebase and Serverless Functions
Stars: ✭ 207 (+263.16%)
Mutual labels:  nuxt, jest
match-screenshot
A simple Jest or Chai matcher to compare screenshots, using Applitools Eyes
Stars: ✭ 14 (-75.44%)
Mutual labels:  jest, puppeteer
energy-use-case-trading-client
Energy Use Case Web UI for Lition Trading Platform
Stars: ✭ 23 (-59.65%)
Mutual labels:  jest, puppeteer
Learn Nuxt Ts
Testing TypeScript for Nuxt
Stars: ✭ 52 (-8.77%)
Mutual labels:  nuxt, jest
N2ex
🌈 V2ex built with Nuxt.js (vue&ssr)
Stars: ✭ 260 (+356.14%)
Mutual labels:  nuxt, jest
Root Cause
🔍 Root Cause is a tool for troubleshooting Puppeteer and Playwright tests. 🔎
Stars: ✭ 205 (+259.65%)
Mutual labels:  jest, puppeteer
Wemake Vue Template
Bleeding edge vue template focused on code quality and developer happiness.
Stars: ✭ 645 (+1031.58%)
Mutual labels:  nuxt, jest
Mostly
They mostly come at night; mostly.
Stars: ✭ 78 (+36.84%)
Mutual labels:  jest, puppeteer
Mhy
🧩 A zero-config, out-of-the-box, multi-purpose toolbox and development environment
Stars: ✭ 128 (+124.56%)
Mutual labels:  zero-configuration, jest
puppeteer-screenshot-tester
Small library that allows us to compare screenshots generated by puppeteer in our tests.
Stars: ✭ 50 (-12.28%)
Mutual labels:  jest, puppeteer
Differencify
Differencify is a library for visual regression testing
Stars: ✭ 572 (+903.51%)
Mutual labels:  jest, puppeteer
Nuxt Starter
Personnal nuxt starter
Stars: ✭ 30 (-47.37%)
Mutual labels:  nuxt, jest
Portal Ui
GDC Data Portal UI
Stars: ✭ 50 (-12.28%)
Mutual labels:  jest
Js Toolbox
CLI tool to simplify the development of JavaScript apps/libraries with little to no configuration. (WORK IN PROGRESS/PACKAGE NOT PUBLISHED).
Stars: ✭ 53 (-7.02%)
Mutual labels:  jest
Typescript Node Rest Starter
Simple starter template for building NODE REST API's using TypeScript
Stars: ✭ 50 (-12.28%)
Mutual labels:  jest

Nuxt Jest Puppeteer

This plugin was made while working on testing for studbits.com. We hope you find it useful!

Installation

npm install nuxt-jest-puppeteer --save-dev

Setup

Add the following to your package.json.

"babel": {
   "presets": ["env"]
},
"scripts": {
  "test": "nuxt-jest-puppeteer",
}

That's it, now you all you need to do is run npm run test to start nuxt and have your complete testing environment setup with jest and puppeteer.

Usage

Along with Jest's global variables, we expose puppeteer's browser object and nuxt's BASE_URL to facilitate testing.

Example usage:

describe('Index page', () => {
    let page
    beforeAll(async () => {
      page = await browser.newPage()
      await page.goto(BASE_URL)
    })
    afterAll(async () => {
      await page.close()
    })

    it('renders index page', async () => {
      const el = await page.$('.index-page')
      expect(el).toBeTruthy()
    })
  })

We also add extra methods to the browser object to make it easy to test Nuxt pages:

  • visitPage, a Function, receives the route as a paramter and returns puppeteer's designated browser page object, powered up with the following nuxt-related methods:
    • html, a Function, returns a promise that resolves to the page's outer HTML.
    • nuxt, Object with the following helpers:
      • navigate, a Function, accepts a path so that you can change pages.
      • loadingData, a Function, that resolves to an object with the current Loading data.
      • routeData, a Function, that resolves to an object with the current Route data.
      • errorData, a Function, that resolves to an object containing any Nuxt errors.
      • storeState, a Function, that resolves to an object with the current Store state.

Example usage:

describe('Index page', () => {
    let page
    beforeAll(async () => {
      page = await browser.visitPage('/home')
    })
    afterAll(async () => {
      await page.close()
    })

    it('renders index page', async () => {
      const elStr = await page.html()
      expect(elStr).toBeTruthy()
    })
  })

For a complete look at testing, see Jest's assertion API and puppeteer's browser API.

Advanced Usage

If you'd like to run Nuxt yourself, set the environment variable SELF_START to true.

In order for Nuxt test helpers to still work, you must set the BASE_URL as well.

Here's an example of how to run nuxt-jest-puppeteer programmatically:

const runTest = require('nuxt-jest-puppeteer')

process.env.SELF_START = true
process.env.BASE_URL = `http:localhost:3000`

Promise.all([runNuxtClient(), runAdonisApi()])
  .then(([client, api]) => {
    let runner
    try {
      runner = runTest()
    } finally {
      Promise.resolve(runner)
        .then(() => {
          client.close()
          api.close()
        })
        .catch(() => process.exit())
    }
  })

License

MIT

Copyright (c) 2017 Studbits

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].