/nightwatch-seo

Nightwatch.js utility assertion for SEO testing in accordance to TELUS digital SEO rules

Primary LanguageJavaScriptISC LicenseISC

Nightwatch SEO version License

DEPRECATED in favor of Lighthouse

Nightwatch.js utility assertion for SEO testing in accordance to TELUS digital SEO rules

Build Status Downloads Code Climate Dependency Status Dependencies

Install

# using npm
npm install --only=production --save @telusdigital/nightwatch-seo

# using yarn
yarn add @telusdigital/nightwatch-seo --dev

Usage

Update your nightwatch config:

{
  custom_assertions_path: ["./node_modules/@telusdigital/nightwatch-seo/assertions"]
}

Use in your tests:

module.exports = {
  'Test': function (browser) {
    browser.assert.seo('#app', {
      scoped: true
    })
  }
}

API

browser.assert.seo(context, options)

Analyzes the defined context against SEO rules

Name Type Default Required Description
context String 'html' ✖️ A CSS selector that selects the portion(s) of the document that must be analyzed
options Object null ✖️ configure how SEO assertion operates

options

Name Type Default Required Description
meta Boolean false ✖️ check page meta
titleRegExp RegExp /.* - TELUS.com/ ✖️ configurable regex for <title> assertions

SEO Rules

This is a work in progress, checklist below indicates what has been implemented to date:

Layout
  • <h1/>

    • element should be unique and found only once per page
  • <img>

    • element should have alt attributes
    • element src attribute should be separated by underscores
Meta
  • Page URL

    • URL phrase should be separated with dashes (-) between each word
  • <link rel="canonical">

    • element should exist and be unique
    • element href attribute should not be empty
    • element href attribute should exclude provincial parameters, tracking codes and any other extra parameters & query strings
  • <title>

    • element should exists and be unique
    • element should conform to pattern ( - TELUS.com)
    • element content length should be not exceed 65 characters
  • <meta name="description">

    • element should exists and be unique
    • element content length should not exceed 155 characters
Social Meta
  • <meta property="og:title">

    • element should exists and be unique
    • element should contain company domain name (TELUS.com)
    • element should use a spaced dash (-) to separate sections
    • element content length should be not exceed 65 characters
  • <meta property="og:description">

    • element should exists and be unique
    • element content length should not exceed 155 characters
  • <meta property="og:url">

    • element should exists and be unique
    • element content attribute should not be empty
    • element content attribute should exclude provincial parameters, tracking codes and any other extra parameters & query strings
  • <meta property="og:image">

    • element should exist and be unique
    • element should contain an image URL that best represents the page
Structured Data
For product detail pages ie phones and accessories
  • "@type": "Product"

    • element should exist
  • "name"

    • element should exist
  • "description"

    • element should exist
  • "image"

    • element should exist
  • "brand"

    • element should exist
  • "@type": "Offer"

    • element should exist
  • "price"

    • element should exist
  • "priceCurrency"

    • element should exist
  • "availability"

    • element should exist
  • "url"

    • element should exist
For video content types
  • "@type": "VideoObject"

    • element should exist
  • "name"

    • element should exist
  • "description"

    • element should exist
  • "thumbnailUrl"

    • element should exist
  • "uploadDate"

    • element should exist and in ISO 8601 format

©️ TELUS digital ·  License: ISC ·  Github: @telusdigital ·  Twitter: @telusdigital