npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

polaris-suite

v0.7.2

Published

easy to use, light weight and collaborative automated testing suite for web applications

Downloads

40

Readme

Polaris suite is a easy to use, light and collaborative web tesiting package for javascript and typescript projects.

Visit polaris-suite docs for detailed information.

Table of Contents

Getting Started

Install Polaris-suite using npm:

npm install --save-dev polaris-suite

Let's create your first test. Start by creating a function in a file multiplication.js.

function multiply(a, b) {
    return a * b;
}
module.exports = multiply;

Or, for es6

export function multiply(a, b) {
    return a * b;
}

Then, create the actual test inside file multiplication.test.js ideally located inside test folder

import { test, expect } from "polaris-suite";
import { multiply } from "path-to-multiplication.js";

test('multiply 3 * 4 equals 12', () => {
    expect(multiply(3, 4)).equalsTo(12);
});

Note: As of now polaris-suite only supports commonJS module and not es6

Now, Add the script in package.json to run the test

{
    ... ,
    "scripts": {
        ... ,
        "test": "polaris test"
    },
    ...
}

Note: the path must be provided till the folder the test file is located and not the file name itself

Finally, run npm test in the terminal and the following message will be printed in the console:

PASS ✓ (multiply 3 * 4 equals 12)

Contragtulation, you just created your first test case in polaris-suite and executed it

For other functions and their property that you can use can be found in the Docs

Using Typescript

Polaris Suite will support typescript out of the box. There will be no need for any extra configuration to get started with typescript with polaris suite.

Note: It is not supported yet and will be added very soon

Documentation

For detailed documentation docs

Functions that can be used

function | Parameters | Description --|--|-- expect() | actual: any | This is the most basic function that can be used in polaris-suite. It takes in a parameter that can be anything. call() | fn: function, params?: any[ ] | This is another basic function that is used to test functions easily. It takes a function and optionally takes params array. component() | ele: HTML element | This is another basic function that is used to test component easily. It takes a HTML element. test() | name: string, fn: function | This is the function that will be treated as a test case in polaris-suite. It takes a name, and a function with no parameters and return value. suite() | name: string, fn: function | This is the function that is used to group the test cases and create a test suite in polaris-suite. It takes a name, and a function with no parameters and return value. ~~result()~~ | | This is the function that will soon be not needed to be explicity called but as of now has to be called in order to get summary of results when using suite

expect

The most basic function that can be used to test the equality or test the expectation of any kind of data (string, boolean, function, etc).

Parameters:

  • actual: any

Returns:

  • void

Properties

  • equalsTo() : takes a parameter expected of any type to check euqality with the actual value
  • toBeString() : check if actual is of string type
  • toBeNull() : check if actual is of null type
  • toBeBoolean() : check if actual is of boolean type
  • toBeObject() : check if actual is of object type
  • not : check the negation of equality
    • equalsTo()
    • toBeString()
    • toBeNull()
    • toBeBoolean()
    • toBeArray()
    • toBeObject()

call

Another basic function that can be used to test the return value or the expected return value of functions

Parameters:

  • fn: any
  • params?: any[ ]

Returns:

  • void

Properties

  • returns() : takes a parameter result of any type and an optional parameter of type WithDataOptions to check euqality with the return value of the function.
  • iterateWithData() : similar to returns expect it takes in a parameter of type DataTable and an optional parameter of type WithDataOptions and iterate over those value to check return value for multiple parameters.
  • not : check the negation of returns
    • returns()

component

Another basic function that can be used to test the html component

Parameters:

  • ele: HTML element

Returns:

  • void

Properties

  • haveStyle() : takes a parameter style of object type to check if the element has the provided style
  • contains() : takes a parameter child of type either string or HTML element and check if it is the child element of ele
  • not : check the negation
    • haveSytle()
    • contains()

test

This function is used to create a test case in polaris-suite. It is recommended to use it alongside suite() function but can be used alone too.

Parameters:

  • name: string
  • fn: function

Returns:

  • void

Properties: no properties, standalone function

suite

This function is used to group similar test cases together and run at once with detailed result of each test cases.

Parameters:

  • name: string
  • fn: function

Returns:

  • void

Properties: no properties, standalone function

~~result~~

has been called implicitly, no more need of calling explicitly

Helper function that will soon be no longer needed to be explicitly executed but for now needs to be called when using suite function to get result summary.

Parameters: no parameters

Returns:

  • void

Properties: no properties, standalone function

Types

It is a bare minimum guide to some custom types in polaris-suite to better understand its functions and functionality.

To dive deeper, head to docs - types

DataTable

type:

type DataTable = Array<{ arg: Array<any>, result: any, isNotEqual?: boolean }>

description:

used in parameter typing of call() function to take in the array of parameters to be passed in iterateWithData() function.

WithDataOptions

type:

type WithDataOptions = {
    async?: boolean;
}

description:

used in parameter typing of call() function as the optional parameters to specify the function has other properties like asynchronous, etc