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

yamlspec

v1.0.7

Published

Generate Jasmine-compatible .js specification files from .yaml-formatted specification file

Downloads

1

Readme

yamlspec

Generates JavaScript package specification files from a .yml specification file, giving both developers and QA team a quick and productive tool for writing specifications.

Installation

Install yamlspec globally so you can invoke it as command-line program:

npm i -g yamlspec

Check yamlspec runs at command-prompt:

yamlspec -V
v1.0.5

YML-format specifications

To expedite specification formulation process, yamlspec introduces its alternative to traditional .js code. Those familiar with Jasmine and its related specification frameworks based on .js will recognize the describe and it entries.

The example below contains specifications for <packageName> package, which is invoked with a require statement. The package is placed in a constant whose name is also <packageName>.

The specification contains two describe sections, aka "test sets", inside the items key. Each section contains its own test cases as it entries. The test cases fall under a test set's items.

package:
    - require: <packageName>
    - const: <packageName>
items:
    - describe:
        what: <packageName>
        items:
            - it: should have method a
    - describe:
        what: method a
        items:
            - it: should return a string
            - it: should return an empty string when input parameter is empty
            - it: should return en empty string when input parameter is not specified
            - it: should return an empty string when input parameter has only delimiters 

JavaScript Code

const yamlspec = require('yamlspec')

let sourceFilename = '/path/to/specsInYamlFormat.yml';

let source = yamlspec.loadFile(sourceFilename)
yamlspec.renderFile('/path/to/spec/folder/specfilename.js', source);

CLI

yamlspec [options] sourceFilename
yamlspec -h
Usage: yamlspec [options] sourceFilename

YAML to Jasmine specification generator.

Options:
  -V, --version                      output the version number
  -o, --output <outfilename>         name of extended specification filename
  -s, --suffix <suffix>              suffix text to go after test basename (default: "Spec")
  -p, --path <outpath>               root path for generated specification files (default: "./spec")
  -t, --templatepath <templatepath>  path to templates (default: ".\\bin\\templates")
  -h, --help                         display help for command

Examples

  1. Create your working folder with mkdir myfolder, cd myfolder, and create mypackage.yml as follows:
package:
    request: fs
    const: fs

items:
    - describe:
        what: Simple test suite
        items:
            - it: First test description
            - it: Second test description
            - it: Third test description
  1. Run yamlspec
yamlspec mypackage

yamlspec generates the ./spec/mypackageSpec.js

const fs = require('fs');

describe('Simple test suite', () => {

    // First test description
    it('First test description', () => {
        //
        // @todo First test description
        //
        expect(0).toEqual(1)
    })

    // Second test description
    it('First test description', () => {
        //
        // @todo Second test description
        //
        expect(0).toEqual(1)
    })

    // Third test description
    it('Third test description', () => {
        //
        // @todo Third test description
        //
        expect(0).toEqual(1)
    })
})
  1. Invoke Jasmine, confirming your specifications are available. All will fail.
jasmine

API

Functions

loadFile(sourceFilename, [options]) ⇒ Object

Load source file with YAML specification.

Kind: global function
Returns: Object - Specification object.

| Param | Type | Default | Description | | --- | --- | --- | --- | | sourceFilename | string | | Source filename in .yaml format | | [options] | Object | {} | File loading options. |

render(source, [options]) ⇒ string

Render extended specification content.

Kind: global function
Returns: string - Expanded resulting specification content.

| Param | Type | Default | Description | | --- | --- | --- | --- | | source | Object | | Specification object. | | [options] | Object | {} | Rendering options. |

renderFile(outputFilename, source, [options])

Render file with exptended specification content.

Kind: global function

| Param | Type | Default | Description | | --- | --- | --- | --- | | outputFilename | string | | Path-like string of output filename. | | source | Object | | Specification object. | | [options] | Object | {} | Rendering options. |