-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add ink! e2e-tests #196
Add ink! e2e-tests #196
Conversation
…test generate` command to generate types for mocha tests, add test_helpers for ink_e2e tests, remove generate types from compile, add ink_e2e tests to tamplates
src/commands/init/index.ts
Outdated
@@ -269,6 +269,15 @@ export class Init extends SwankyCommand<typeof Init> { | |||
runningMessage: "Copying contract template files", | |||
}); | |||
|
|||
this.taskQueue.push({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This task needs to be perform only for contractTemplate=psp22
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal is to set up the correct testing strategy based on the development dependencies used:
- ink! end-to-end (E2E) testing for ink! smart contracts.
- Mocha TypeScript (TS) testing for ask! smart contracts.
Since our current contract templates are for ink! contracts, there is no need to copy TS tests with copyContractTemplateFiles
on the init
(generate only) command and on the contract new
command. Only E2E test helpers are needed for psp22 contracts template.
The tricky part is on the init -c
(convert) command when converting an existing project into a Swanky project. Then, we need to first detect the development dependencies used.
However, to be honest, I don't see comprehensive support for ask! in Swanky. The Astar documentation recommends using ink!. Also this issue mention that:
If user choses ink! as a language, tests should be scaffolded using the ink! e2e framework. Using mocha (node.js) is redundant.
@prxgr4mm3r I suggest removing scaffolding for TS tests by default in the following steps:
- Refactor
copyContractTemplateFiles
by removing the test copy. - Refactor
copyTestHelpers
, renaming it toprepareTestFiles
and accepting a "type" argument of type "e2e" or "mocha". Oninit
(generate only) and on thecontract new
command, it runs asprepareTestFiles("e2e")
for psp22 templates. - Preserve the previous folder structure for tests with
contract test
(no need for a test folder with an index.ts). Preserve the actual optional--mocha
flag to run TS tests but perform agenerateTypes
. Otherwise, E2E tests run by default. - Create a dedicated generate subcommand folder containing 2 commands:
generate types
(previousTypegenCommand
)generate test
with contract name argument. By default, it performsprepareTestFiles("e2e")
unless an optional template is passed as flag, then it scaffolds TS tests in the selected contract test folder with prepareTestFiles("mocha"). This is similar to the actual test copy incopyContractTemplateFiles
. In both cases, if a "tests" folder already exists when runninggenerate test
, prompt a warning confirmation to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.