npm.io
1.2.4 • Published 3 years agoCLI

dem-testing-tool

Licence
ISC
Version
1.2.4
Deps
7
Size
30 kB
Vulns
0
Weekly
0

Dem Testing Tool

A Node.js Command Line Application

Table of Contents

General Information

This is a command line app for automate some of the test we made for our DEM.

Setup

If you don't have node.js installed, please download and install it from here

https://nodejs.org/it/download/

Open your terminal and install the package globally:
  • npm i -g dem-testing-tool

Important: Open your terminal as administrator on Windows, on Mac OS & Linux you will need to use sudo npm i -g dem-testing-tool

Important: In Windows you could need to edit the ExecutionPolicy settings to use this command line:

  • Open PowerShell as administrator and paste this command:
    • Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

Reference: https://docs.microsoft.com/it-it/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.2

Important: In your mjml file add this classes:

  • Facebook anchor: class="facebook-link"
  • Youtube anchor: class="youtube-link"
  • Linkedin anchor: class="linkedin-link"
  • Disclaimer (sicurezza) anchor: class="disclaimer-link"
  • Disclaimer text: css-class="disclaimer-text"

How to update

Open your terminal and install the package globally:
  • npm update -g dem-testing-tool

Important: Open your terminal as administrator on Windows, on Mac OS & Linux you will need to use sudo npm update -g dem-testing-tool

Usage

  1. Navigate inside the general dem folder - (NOT the id dem folder)
    • Example:
      • Here > Motore Italia Digitale - soluzioni e-commerce_v3
      • Not here > Motore Italia Digitale - soluzioni e-commerce_v3/5449/
  2. Open the terminal, and launch the command dem test
  3. Wait for the test to complete

Technologies Used

  • Node.js
  • cli-color
  • glob
  • html-validator
  • signale
  • cli-color
  • cli-progress

Tests

List of the tests here:
















Regex: /lang\=\"it\"/g

  • Function name => checkHtmlLang()

Regex: /href="(.*?)"/g - /(\s)/

  • Function name => testSpacesInLink()



Edit Command

Example usage

dem edit --rename "folder name" or dem edit -r "folder name"

where the "folder name"is the target directory.

You can also use the command dem edit -h for more details.

This command will rename your folder in this way:

  1. remove special characters - regex: regex(/[!$%^&*()+|~={}\[\]:\/;<>?,\.@#]/g)
  2. replace accent letter with a normalized letter
  3. replace _ with - - regex: regex(/_/g, "-")
  4. replace a space with - between two characters - regex: regex(/\b\s\b/g, "-")
  5. replace remove all spaces - regex regex(/\s/g, "")
  6. lowercase all the characters - .toLocaleLowerCase()

Screenshot

Example screenshot

Changelog

07/04/2023
  • Added a new test testPreheaderSpaces to check preheader spaces
  • Added a new test testImageAltSpaces to check alts spaces
23/08/2022
  • Added extensions (jpeg and gif) to testUnusedImages test
29/07/2022
  • Added a new test checkHtmlLang to check the property lang="it"
21/07/2022
  • Added a new test checkBottomVariables to check the presence and the correct name of two variables ${package_code}$ ${surrogate_key}$
29/06/2022
  • Added a throw Error() when the command is NOT launched into the main directory.
07/07/2022
  • Added dem edit --rename <folder> command to rename dem folders correctly
  • Add a check for testImagesNames() if uppercase exists
25/11/2022
  • Added a new test testSpacesInLink to check the presence of spaces inside a href=""