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

codeceptjs-loki

v0.0.5

Published

Codecept Helper with in memory databse (provided by loki.js) for data driven testing and result capturing.

Downloads

7

Readme

Table of Contents

Intro

Codecept Helper with in memory databse (provided by loki.js) for data driven testing and result capturing. An example scenario can be found below

Config

Add to codecept.conf.js with:

exports.config = {
    helpers: {
        Nightmare: {
            url: "http://localhost"
            },
        Loki: {
            "require": "node_modules/codeceptjs-loki",
            "dbName": "db.json",
            "dbSeed": true
        }
    }
    /*...some config*/
}

or to codecept.json with:

{
  "helpers": {
    "Nightmare": {
      "url": "http://localhost"
    },
    "Loki": {
      "require": "node_modules/codeceptjs-loki",
      "dbName": "db.json",
      "dbSeed": true
    }
  }
}

Loki

Extends Helper

Helper with in memory databse for data driven testing and result capturing.

Parameters

  • config

constructor

Parameters

  • config Object configuration can be overridded by values found in `codecept.json

addCollection

Will check for an existing collection of the same name and return that, if it already exists.

Parameters

  • collection string creates a collection with supplied name.

findCollection

Parameters

  • collection string name of desired collection.

removeCollection

Removes a matching collection.

Parameters

  • collection string finds a collection that matches the supplied name

insert

Inserts records from the supplied data to a matching collection.

Parameters

  • collection string name of desired collection.
  • data Array takes an array of objects as records for the destination collection.

clear

Clears data from a matching collection.

Parameters

  • collection string name of desired collection.

find

Searches the Users colection for matching values.

Parameters

  • collection string name of desired collection.
  • query Object used in searching the destination collection for matching values.

Examples

// Searches for a user with an email of "[email protected]"
I.find("Users",{email: "[email protected]"})

Returns Array Returns an array of objects that match.

findOne

Effectively the same as find() but returns a single object rather than an array.

Parameters

  • collection string name of desired collection.
  • query Object used in searching the destination collection for matching values.

findAndUpdate

Finds a list of values based on the supplied query and runs an update function on each result.

Parameters

  • collection string name of desired collection.
  • query Object used in searching the destination collection for matching values.
  • updateFunction function executes against each of the results in the result array.

Examples

// Before {email: "[email protected]", firstname: "Some", surname: "One", address1: "1 Some Place"}
I.findAndUpdate("users",{email: "[email protected]"},(res)=>{res.number = "01234567890"})
// Find updated record
I.findOne("Users",{email: "[email protected]"})
// After {email: "[email protected]", firstname: "Some", surname: "One", address1: "1 Some Place", number:01234567890}

findAndRemove

Like findAndUpdate() but finds a record in a collection and removes it.

Parameters

  • collection string name of desired collection.
  • query Object used in searching the destination collection for matching values.

importData

Imports data from a directory into a collection. Uses file names to create a collection of the same name and imports the contents of the file as records to the destination.

Parameters

  • dir string takes a directory as a string.

Example

  Feature("Order - User Details");
  let user, claimId;
  Scenario("User Details", function (I) {
      //Retrieving some user form data that was seeded before the test execution.
      //The arguments are the document store being queried and the query object itself.
      //The first matching value is selected, but this can just as easily be used to randomise the selected user.
      user = yield I.findOne("users", {
          email: "[email protected]"
      });
      //testId is generated elsewhere per run
      I.fillField("orderNumber", testId);
      I.dontSee("Order number is required");
      I.fillField("firstName", user.firstname);
      I.dontSee("First name is required");
      I.fillField("surname", user.surname);
      I.dontSee("Surname is required");
      I.fillField("address", user.address);
      I.dontSee("Address is required");
      I.fillField("email", user.email);
      I.dontSee("Must be a valid email");
      I.click("Save");
      //Example custom helper function to grab the "order id" from the url.
      claimId = yield I.grabUrlPart(4);
  });
  AfterSuite((I) => {
      //Create a new document store for orders before inserting relevant data from the test above.
      //This becomes queryable in later scenarios/features, like users was above. Thus allowing validation against known values while still allowing the use dynamic data to drive testing.
      I.addCollection("orders");
      I.insert("orders", {
          orderId: claimId,
          orderNumber: testId,
          email: user.email,
          fullName: `${user.firstname} ${user.surname}`,
      });
  });