New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

assembly-diagrams

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assembly-diagrams

Generate Assembly Diagram SVGs

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
286
increased by31.19%
Maintainers
1
Weekly downloads
 
Created
Source

Assembly Diagrams

An Assembly Diagram is a visualisation of a Component Assembly, and a Component Assembly is a set of components that are connected (stacked) in a particular way.

Assembly Diagrams are useful for understanding and designing full-stack automated test suites that can run in milliseconds:

Watch the video

Assembly Diagrams typically visualise three kinds of components:

  • #FFB000 Test components
  • #DC267F Infrastructure components
  • #648FFF Production components

You can think of each component as a "lego brick" with three characteristics:

  • The top studs of the brick represent the component's contract (the interface it implements)
  • The brick itself is how the component fulfils the contract (its implementation)
  • The bottom anti-studs is the contract the component needs (its dependency)

There can be multiple implementations of the same interface. This makes it possible to create a wide range of Component Assemblies. If you've ever played with lego you know this.

Full StackDOM-HTTP-DomainDOM-DomainHTTP-DomainDomain
testtesttesttesttest

Each of these assemblies make tradeoffs between three important aspects of automated tests:

  • Speed
  • Confidence (how much is tested)
  • Diagnostic precision (how easy it is to understand why a test fails)

The general idea is to have more of the fast tests and fewer of the slow ones - as few as you can get away with.

The Dom-Domain assembly exercises most of the functional parts of the stack, yet they typically run in a few milliseconds. This is because there is no I/O in the assembly.

These tests obviously don't provide any confidence about components that are not present. The Full Stack assembly connects all the components similarly to the production environment. Tests in this assembly can be run occasionally, for maximum confidence.

The extremely fast acceptance tests enable high productivity, as developers can get near-instant feedback on their changes. The slower, really thorough ones have a different purpose - to verify that everything works before a commit, and for more thorough CI tests.

Conventions

Components are grouped in the follow categories:

  • test code - green
  • infrastructure - pink
  • production code - light blue

This makes it easier to distinguish between different types of components. It also makes it easier to quickly spot what's essential about an assembly:

  • How fast is it? (less infrastructure means faster tests)
  • How much confidence does it give? (less production code means less confidence)
  • How easy is it to diagnose why a test failed? (less production code and infastructure means easier) (fast/slow, with/without infrastructure).

Generate your own assembly diagrams

Write an assembly script by copying and modifying one of the scripts in the assemblies directory. You also need Node.js installed. Then run:

npx assembly-diagrams some-assembly.txt > some-assembly.svg

For more information:

npx assembly-diagrams --help

Build PNGs from SVGs

If you need to convert the SVG file to a PNG file, you can use cairosvg.

brew install python3
pip3 install cairosvg lxml tinycss cssselect
cairosvg --scale 0.4 assembly.svg -o assembly.png

The Makefile contains an example of how to automate generation of SVG and PNG files

Release process

npm version major|minor|patch
npm publish
git push && git push --tags

FAQs

Package last updated on 02 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc