FuelLabs / fuels-ts

Fuel Network Typescript SDK
https://docs.fuel.network/docs/fuels-ts/
Apache License 2.0
44.16k stars 1.34k forks source link

Introduce a TS SDK testing standard and approach #1043

Closed danielbate closed 10 months ago

danielbate commented 1 year ago

As we approach mainnet, it is important we start to implement some stricter testing standards that ensures parity with the protocol/FuelVM and gives us the greatest level of confidence in the changes we are making as uptake in the SDK increases. Additionally, we can consolidate and structure our testing to give greater clarity as to what behaviours we are currently supporting. I would like to propose some MoSCoW testing standards as well as a roadmap of changes to bring the current SDK in line with the standards.

Where we are now

Proposed standards

Tasks (TBD)

This should bring greater clarity to the behaviours supported by the SDK, give greater confidence in the quality of our tests and increase overall coverage as discussed in #753 . All standards and tasks are up for discussion and I would appreciate any insights πŸ˜ƒ

arboleya commented 1 year ago

Good stuff @danielbate! πŸš€

Somewhat related, we also have this:

We can resume the work on it now that #984 was merged.

Here's the spec from the last attempt:

danielbate commented 1 year ago

Good point @arboleya! Will add a task for just that.

arboleya commented 1 year ago

Do you mean other than the #284?

danielbate commented 1 year ago

Apologies, I will not be writing any more issues but I will be using the above task list as a reference to track changes made to bring us closer to adhering to the above standards. So I just meant that I will add another task to the above list, that references #284.

danielbate commented 12 months ago

The above requires updating due to further developments, however this is a good classification from @arboleya that will insight the specification:

Unit = Worries about units, usually mocking external stuff Feature = Worries about features, not mocking or mocking minimally Integration = Tests that target fuel-core locally E2E - Tests that target fuel-core remotely

arboleya commented 12 months ago

Here's how these tests could be spread in directories:

<package-name>
β”œβ”€β”€ src
β”‚Β Β  β”œβ”€β”€ index.test.ts # This would be a unit
β”‚Β Β  └── index.ts
└── test
    β”œβ”€β”€ e2e
    β”œβ”€β”€ feature
    β”œβ”€β”€ fixtures
    β”œβ”€β”€ integration
    └── utils

I ended up with test/{fixtures,utils,feature} in:

It worked great, and I think all packages should segregate their tests.

This goes back to maybe re-distributing all tests from inside fuel-gauge to other packages, and although something like this might not work (because these tests must import from fuels):

One thing that could work is: