testjavascript / nodejs-integration-tests-best-practices

✅ Beyond the basics of Node.js testing. Including a super-comprehensive best practices list and an example app (March 2024)
3.31k stars 196 forks source link

Best practices ideas #43

Open goldbergyoni opened 3 years ago

goldbergyoni commented 3 years ago

Example here: https://github.com/testjavascript/integration-tests-a-z/issues/43

YO, Two strategic topics:

  1. Repo name and concept - Seems like we're going with the repo name: 'Integration Tests Best Practices', Any counter thoughts? Maybe 'Node.js Tests Best Practices' which makes it even more generic, opens the door for more topics but also less focused?

  2. Best practices sketch - I'm including here a first draft of best practices idea and categorization (there will be more and each will include a longer explanation with code example), does this feel like the right taxonomy and will end in interesting content?

The golden principles

Super simple, declarative and short (7 loc) tests

Web server setup (3)

Infrastructure setup (6)

Basic tests - (5)

Tests isolation (8)

Dealing with data (7)

Error handling and metrics

Message queue related testing (8)

Workflow (6)

Other ideas

More will come here. Suggest more?

goldbergyoni commented 3 years ago

The homepage readme moved here: https://github.com/testjavascript/integration-tests-a-z/tree/awesome-homepage

Before I spend a long time writing 40 best practice, LMK if you have thoughts on:

  1. The content - See msg above
  2. The homepage look&feel
  3. The bullet format example (number 1 in the list only, Place a start and stop method within your app entry point)
mikicho commented 3 years ago

Wow, this is amazing!!! Kudos!

  1. I'm fine with Integration Tests Best Practices, this is a broad topic already IMO and if we want to add other topics we can create dedicated repo.
  2. The content looks interesting and valuable!

I just don't understand The golden principles part. what it should contain?

silicakes commented 3 years ago

Hi! Just a couple of thoughts with no specific order here:

Content related aspects

General Aspects

Again, just random thoughts here.

goldbergyoni commented 3 years ago

@silicakes Gold stuff here. First few questions:

Debugging flaky tests and practices to avoid it

Tests should not be flaky, all of these guidelines together are meant to yield great non-flaky tests. Are you referring to specific situation? Why would tests by flaky?

Performance optimization of large test-bases [ expanding on 'optimize speed' ]: Parallel execution, remote execution etc..

Kindly elaborate on remote execution?

Boilerplates for the popular CLIs? i.e testable-nest, testable-express etc..

Sounds interesting, can you share few more works on this idea?

The repos name can contain 'Awesome'

Awesome libs === Links aggregators. We show here a full app with many code and non-trivial practices, is this doing justice with us to put us in the same basket with these libs?

silicakes commented 3 years ago

Tests should not be flaky, all of these guidelines together are meant to yield great non-flaky tests. Are you referring to specific situation? Why would tests by flaky?

That's right, however sometimes you'll get a flaky test for not adhering to these principles and it could be nice to show a debugging workflow to discover the cause

Kindly elaborate on remote execution?

Executing tests over CI, remote machines, executing just a subset of tests during development etc. Basically everything that revolves around providing feedback as fast as possible.

Boilerplates for the popular CLIs

The same way you have templates for various frameworks and tools (i.e npx create-react-app myApp --template typescript), you can have a couple to set up the initial testing configuration and bootstrap

Awesome libs

I agree, we're not going to aggregate links, disregard that. (We might create an aggregation for testing libraries and tools though, which can be a nice appendix for these practices)