Skip to content

cli: allow execute custom test command#550

Merged
armaniferrante merged 10 commits into
solana-foundation:masterfrom
fanatid:cli-custom-test-cmd
Jul 29, 2021
Merged

cli: allow execute custom test command#550
armaniferrante merged 10 commits into
solana-foundation:masterfrom
fanatid:cli-custom-test-cmd

Conversation

@fanatid
Copy link
Copy Markdown
Contributor

@fanatid fanatid commented Jul 27, 2021

Closes #426

Usage example:

anchor test --cmd "npx ts-node node_modules/.bin/tape tests/*.ts"

@armaniferrante
Copy link
Copy Markdown
Contributor

What do you think of adding this to the [scripts] section instead of the --cmd option?

So your example turns into

[scripts]
test = "npx ts-node node_modules/.bin/tape tests/*.ts"

Then run anchor test.

@fanatid
Copy link
Copy Markdown
Contributor Author

fanatid commented Jul 27, 2021

If we add test field to scripts section which will be used by anchor test what does anchor run test should do?

@armaniferrante
Copy link
Copy Markdown
Contributor

armaniferrante commented Jul 27, 2021

If we add test field to scripts section which will be used by anchor test what does anchor run test should do?

Perhaps the same as anchor test? I'm not sure.

I'm thinking it'll be convenient for some of the scripts to have special behavior similar to npm, for deploys, tests, and publishing builds (once that's ready).

@armaniferrante
Copy link
Copy Markdown
Contributor

Shall we add a simple test in one of the examples?

@fanatid
Copy link
Copy Markdown
Contributor Author

fanatid commented Jul 28, 2021

Yeah, I thought about example and where we should document the new feature. Maybe we should introduce breaking change and require test field in scripts section? i.e. move mocha/ts-mocha from cli binary to config and create it by default?

@armaniferrante
Copy link
Copy Markdown
Contributor

Yeah, I thought about example and where we should document the new feature. Maybe we should introduce breaking change and require test field in scripts section? i.e. move mocha/ts-mocha from cli binary to config and create it by default?

I don't have strong opinions. Let's file an issue and consider the breaking change separately.

@fanatid
Copy link
Copy Markdown
Contributor Author

fanatid commented Jul 28, 2021

Updated.

  • Use command from [scripts] + test
  • On anchor init add default [scripts] + test for mocha/ts-mocha
  • Instead file allow to pass custom arguments

@armaniferrante armaniferrante merged commit 690c413 into solana-foundation:master Jul 29, 2021
@fanatid fanatid deleted the cli-custom-test-cmd branch July 30, 2021 04:40
Otter-0x4ka5h pushed a commit to Otter-0x4ka5h/anchor that referenced this pull request Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow other test framework than mocha for anchor test.

2 participants