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

cfa-cypress

v1.0.3

Published

## API

Downloads

5

Readme

CFA Cypress Helpers

API

CFA Cypress provides several useful helper methods to make writing Cypress tests easier and more efficient.

Menu Helpers

getMenu(String:locationNumber, Boolean:catering = false, String:destination = 'pickup')

Fetches the menu for a given location and destination. Returns a Promise that resolves with the menu API response.

getMenu('01668', true, 'pickup')
.then(menuResponse => console.log(menuResponse.body))

getMenuMap(String:locationNumber, Boolean:catering = false, String:destination = 'pickup')

Similar to getMenu, but returns a Promise that resolves with an object representing an easier to use map of the menu.

getMenuMap('01668', true, 'pickup')
.then(({ parentTagsByTag, itemsByItemGroupIdAndTag, categories }) => console.log(parentTagsByTag, itemsByItemGroupIdAndTag, categories))
/* {
    8OZ_BARBEQUE_SAUCE: 500011,
    8OZ_BUFFALO_SAUCE: 500011,
    8OZ_CFA_SAUCE: 500011,
    8OZ_HONEY_MUSTARD: 500011,
    8OZ_POLYNESIAN: 500011,
    8OZ_RANCH: 500011,
    8OZ_SAUCES: 500058,
    8OZ_SAUCES_PAID: 500058,
    8OZ_SRIRACHA: 500011,
    ...
},
{
    500001: {CHICK_N_MINIS_TRAY_SMALL: {…}, CHICK_N_MINIS_TRAY_LARGE: {…}},
    500002: {YOGURT_GREEK_PARFAIT_COOKIE: {…}, YOGURT_GREEK_PARFAIT_GRANOLA: {…}},
    500003: {FRUIT_CUP_SMALL: {…}, FRUIT_CUP_MEDIUM: {…}, FRUIT_CUP_LARGE: {…}},
    ...
},
[
    {items: Array(8), desktopImage: "https://www.cfacdn.com/img/order/Catering/Breakfast/Chicken_biscuit.png", mobileImage: "", ...},
    ...
]*/

lookupPriceOfItem(Object:menuMap, String:parentTag, String:childTag)

Returns the itemPrice attribute of the item with the given childTag in Number format.

it('Looks up the price of an item', () => {
    getMenuMap('01668', true, 'pickup').then((menuMap) => {
      const price = lookupPriceOfItem(menuMap, 'CHICK_N_STRIPS_TRAY_HOT_SMALL', 'CHICK_N_STRIPS_TRAY_HOT_SMALL');
      expect(price).to.equal(27.5)
    })
  })

Okta

oktaLogin(String:username, String:password)

Logs into Okta with the given credentials and sets the relevant cookies. This should be called in the before hook or in the first step definition if using Cucumber.

IMPORTANT: DO NOT STORE PASSWORDS IN GIT. Create a cypress.env.json file, and add it to your .gitignore. Then add key-value pairs for username and password. Pass them to the function like this: Cypress.env('username'). You have been warned.

describe('My App', () => {
  before(() => {
    oktaLogin(Cypress.env('username'), Cypress.env('password'));
  })
  
  it('does stuff', () => {
    // Test here...
  })
})
// cypress/support/step_definitions.js
given('I launch the app', () => {
  oktaLogin(Cypress.env('username'), Cypress.env('password'));
  cy.visit('/')
})

Profile

createNewProfile(String:token, String:sessionId)

Create a new CFAOne profile for use in automation testing. This is necessary because having an excessive number of orders for one particular account (i.e. if one account is continually used for automation testing), lookup times in Dynamo can slow to a crawl.

Returns a Promise that resolves with token, sessionId, and username, password of the new account.

createNewProfile(Cypress.env('TOKEN'), Cypress.env('sessionId'))
.then((email, password, token, sessionId) => console.log(email, password, token, sessionId))

login(String:email, String:password, String:token, String:sessionId)

Logs into an account via the API.

Returns a Promise that resolves with the API response.

login(Cypress.env('username'), Cypress.env('password'), Cypress.env('TOKEN'), Cypress.env('sessionId'))
.then(apiResponse => console.log(apiResponse))

Or, when used with createNewProfile:

createNewProfile(Cypress.env('TOKEN'), Cypress.env('sessionId')).then(login);