Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not a bug or a feature: Programmatic API for unit testing architecture #336

Open
pbadenski opened this issue Jul 20, 2020 · 2 comments
Open
Labels
enhancement this will make dependency-cruiser sweeter
Projects

Comments

@pbadenski
Copy link

I'm toying with an idea of unit testing our design using mocha (influenced by Java's ArchUnit: https://www.archunit.org/getting-started) - as an alternative to using declarative dependencies/validation configuration.

API documentation mentions programmatic access, but doesn't really give enough context to build an efficient mocha test suite. One of my requirements would be that generating dependency graph and then defining and applying rules would ideally be separate API calls. Eg.:

const depcruise = require("dependency-cruiser").cruise;

const dependencies = depcruise(["src"]).output;

const rule = buildRule({ forbidden: { ... }}).

rule.validateAgainst(dependencies);

Is it something that's possible at the moment or would it require extensions to the programmatic API?

@sverweij sverweij added this to backlog in roadmap via automation Jul 22, 2020
@sverweij sverweij added the enhancement this will make dependency-cruiser sweeter label Jul 22, 2020
@sverweij
Copy link
Owner

hi @pbadenski that's an interesting idea. As you already correctly surmised this is currently not possible with the API. But it shouldn't be too hard to expose some of dc's innards to make it possible. If I have some time later this week I'll see if I can whip up a first iteration to gauge feasibility.

@pbadenski
Copy link
Author

Thanks, I've used existing output to quickly custom hack a few assertions we needed. We're now running dependency cruiser with mocha - just thought I'll share this with you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement this will make dependency-cruiser sweeter
Projects
Status: backlog
roadmap
  
backlog
Development

No branches or pull requests

2 participants