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

gpc-test-data

v1.2.0

Published

This precompiler inserts external test data as example rows.

Downloads

26,076

Readme

gpc-test-data

Downloads Version@npm Version@git CI Docs

This precompiler can load external data (JSON, CSV, or XLS/XLSX) into the examples table.

Usage

'use strict';
const compiler = require('gherking');
const { default: TestData } = require('gpc-test-data');

let ast = await compiler.load('./features/src/login.feature');
ast = await compiler.process(
  ast,
  new TestData({
    defaultValue: "-"
  })
);
await compiler.save('./features/dist/login.feature', ast, {
  lineBreak: '\r\n'
});
'use strict';
import {load, process, save} from "gherking";
import TestData from "gpc-test-data";

let ast = await load("./features/src/login.feature");
ast = await process(
  ast,
  new TestData({
    defaultValue: "-"
  })
);
await save('./features/dist/login.feature', ast, {
  lineBreak: '\r\n'
});

Tags

In the feature file, for each Examples, one of the following tags can be set:

  • @load_json(path) to load the data from a JSON file
  • @load_csv(path) to load the data from a CSV file
  • @load_xls(path) to load the data from an XLS/XLSX file, from the first sheet
  • @load_xls(path,sheet) to load the data from an XLS/XLSX file, from the given sheet
  • @load_http(url) to load the data from an HTTP source (a JSON response of an object array)

For each tag, the path must be either a relative (from cwd) or an absolute path to the file, including the file name and extension.

Formats

There are some restrictions on the various data formats:

  • For JSON, the content of the JSON file should be an array of objects, where the key of the object properties will be mapped to the examples columns.
  • For CSV and XLS/XLSX, the first non-empty row must contain the header/column names, which will be mapped to the examples columns.
  • For CSV, the csv-parse tool is used to parse the CSV files, see its documentation for the particular specialties of its parsing and requirements for a CSV file (for parsing, an adaptive configuration is set - columns, skipping empty lines, trimming, auto-BOM, auto-delimiter).
  • For XLS/XLSX, the xlsx tool is used to parse the XLS/XLSX files, see its documentation for the particular specialties of its parsing and requirements for an XLS/XLSX file (for parsing, an adaptive configuration if set - removing blank rows, skipping hidden rows, parsing number; additionally the CSV parsing options from the previous point).

Configuration

The precompiler supports the following configuration options to be set:

| Option | Type | Description | Default | | :----------------: | :--------------: | :---------------------------------------------------------------------------------------------------- | :------ | | keepTag | boolean | Whether the load-tags should be kept or removed. | false | | defaultValue | string\|number | The default value to be added to the table, if a column/value is not found. | "" | | appendData | boolean | Whether the loaded data should be appended to the existing rows of the examples table or overwritten. | true | | ignoreKeyCase | boolean | Whether the casing of the example columns and data columns should be ignored. | true | | addSourceComment | boolean | Whether a comment should be added to the example, indicating the source and the data type. | false | | allowEmptyData | boolean | Whether empty data files are allowed to be loaded, or error should be thrown. | false |

Other

This package uses debug for logging, use gpc:test-data :

DEBUG=gpc:test-data* gherking ...

For detailed documentation see the TypeDocs documentation.