@tracespace/fixtures

4.2.7 • Public • Published

tracespace fixtures

latest next david

Test fixtures for tracespace projects

This module is a collection of data, including real-world open-source Gerber and drill files, used to drive tests on tracespace projects. It's published to npm so that any tool can use this data.

Part of the tracespace collection of PCB visualization tools.

install

Please note: because this package is a collection of test fixtures, it may not follow semver and changes could be introduced in any version bump that cause your tests to fail. You should install an exact version.

npm install --save-dev --save-exact @tracespace/fixtures
# or
yarn add --dev --exact @tracespace/fixtures

usage

const fixtures = require('@tracespace/fixtures')

gerber filenames

gerber-filenames.json is a JSON file with a collection of example Gerber / drill filenames along with what PCB layer type they represent organized by CAD package. This fixture is primarily used to test whats-that-gerber.

const {gerberFilenames} = require('@tracespace/fixtures')
// or
const gerberFilenames = require('@tracespace/fixtures/gerber-filenames.json')

Where gerberFilenames looks like:

Array<{
  /** CAD package, e.g. "eagle" */
  cad: string,
  /** collection of example Gerber and/or drill filenames */
  files: Array<{
    /** filename */
    name: string,
    /** expected whats-that-gerber type */
    type: string
  }>
}>

For non-npm projects, this file is also available via the unpkg CDN:

curl https://unpkg.com/@tracespace/fixtures@${version}/gerber-filenames.json

example boards

@tracespace/fixtures has a collection of sample open-source PCB files to test rendering full circuit boards. This fixture is primarily used to test pcb-stackup and pcb-stackup-core.

const {getBoards} = require('@tracespace/fixtures')

// async
getBoards((error, boards) => {
  if (error) return console.error(error)
  console.log(boards)
})

// sync
const boards = getBoards.sync()

Where boards looks like:

Array<{
  /** name of the board */
  name: string,
  /** path to the board's manifest */
  filepath: string,
  /** array of individual board layers */
  layers: Array<{
    /** name of the layer */
    name: string,
    /** path to the layer's gerber / drill file */
    filepath: string,
    /** basename of filepath */
    filename: string,
    /** format of the file */
    format: 'gerber' | 'drill',
    /** whats-that-gerber type of the layer */
    type: string,
    /** file contents (i.e. results of fs.readFile on filepath) */
    source: string
  }>
}>

gerber specs

@tracespace/fixtures has a collection of simple Gerber and NC drill files to ensure proper rendering of different image primitives and structures. This fixture is primarily used to test gerber-to-svg.

const {getGerberSpecs} = require('@tracespace/fixtures')

// async
getGerberSpecs((error, suites) => {
  if (error) return console.error(error)
  console.log(suites)
})

// sync
const suites = getGerberSpecs.sync()

Where suites looks like:

Array<{
  /** name of the suite */
  name: string,
  /** array of individual specs in the suite */
  specs: Array<{
    /** name of the spec */
    name: string,
    /** category of the spec (matches suite's name) */
    category: string,
    /** path to the spec's gerber / drill file */
    filepath: string,
    /** file contents (i.e. results of fs.readFile on filepath) */
    source: string,
    /** SVG string of the expected render */
    expected: string
  }>
}>

render suite server

Simple server to display the results of a render test. Has a peer dependency on Express, which you must install yourself before usage:

npm install --save-dev @tracespace/fixtures express

Usage:

const {server, getGerberSpecs} = require('@tracespace/fixtures')

const app = server('suite name', getGerberSpecs, getSuiteResults)

app.listen(9000, () => console.log('listening on http://localhost:9000'))

function getSuiteResults(suite, done) {
  // get results of a single suite somehow and pass them to done
  done(null, suiteResults)
}

server is a function that takes:

  1. name - A string name of the server
  2. getSuites - One of getGerberSpecs or getBoards
  3. getSuiteResults - An asynchronous function to render the results of one of the suites from getSuites

getSuiteResults should call its done callback with:

{
  /** name of the suite */
  name: string,
  /** array of spec results in the suite */
  specs: Array<{
    /** name of the spec */
    name: string,
    /** spec render to display (SVG) */
    render: string,
    /** optional comparison render (SVG) */
    expected?: string,
    /** optional test source to display */
    source?: string,
  }>
}

Readme

Keywords

none

Package Sidebar

Install

npm i @tracespace/fixtures

Weekly Downloads

16

Version

4.2.7

License

MIT

Unpacked Size

3.9 MB

Total Files

227

Last publish

Collaborators

  • mcous