Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fixturio-test

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fixturio-test

Fixtures

  • 0.0.12
  • unpublished
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

fixturio

test Coverage Status npm shield

Installation

yarn add -D fixturio

Fixturio excels at resolving complex object dependencies. It automatically analyzes the dependencies between objects and determines the optimal order in which they should be loaded. This library utilizes the duck typing approach. If an exported class has an install method, it will be marked as a fixture.

Inject dependencies

To inject dependencies into the constructor, you need to define the getInjectDependencies method in the fixture class and provide a container that implements the ServiceContainerInterface interface. Note that the order of definition is important. Dependencies will be injected in the same order they are defined.

export class ArticleFixture implements FixtureInterface<unknown>, DependencyInjectable {
  //1, 2
  constructor(
    private readonly objectSaver: ObjectSaver,
    private readonly somethingElse: SomethingElse
  ) {
  }

  getInjectDependencies(): readonly InjectDependency[] {
    //1, 2
    return [ObjectSaver, SomethingElse];
  }

  async install(fixtureSetupBucket: FixtureSetupBucket): Promise<unknown> {
    //...
  }
}

Dependencies between fixtures

To define dependencies between fixture classes, you need to implement the getFixtureDependencies method.

//AFixture.ts
export class AFixture implements FixtureInterface<unknown>, DependentFixtureInterface {
  getFixtureDependencies(): readonly FixtureDependency[] {
    return [BFixture];
  }

  async install(fixtureSetupBucket: FixtureSetupBucket): Promise<unknown> {
    //...
  }
}

//BFixture.ts
export class BFixture implements FixtureInterface<unknown> {
  async install(fixtureSetupBucket: FixtureSetupBucket): Promise<unknown> {
    //...
  }
}

Examples

More examples can be fond in examples folder

License

MIT

Keywords

FAQs

Package last updated on 02 Jul 2023

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