Skip to content
This repository was archived by the owner on Aug 24, 2023. It is now read-only.

Move ./ts-tests/containers into ./packages/testcontainers #78

Closed
Tracked by #86
fuxingloh opened this issue Sep 8, 2022 · 1 comment · Fixed by #67
Closed
Tracked by #86

Move ./ts-tests/containers into ./packages/testcontainers #78

fuxingloh opened this issue Sep 8, 2022 · 1 comment · Fixed by #67
Assignees
Labels

Comments

@fuxingloh
Copy link
Contributor

What would you like to be added:

As per the title, moving it to a publishable standalone package.

Why is this needed:

Following mono-repo design detailed in #42.

Currently, it's blocked by:

/triage accepted
/area packages
/packages testcontainers

@fuxingloh
Copy link
Contributor Author

/assign @fuxingloh I'm working on it with a pending PR

fuxingloh added a commit that referenced this issue Sep 13, 2022
…pace design (#86)

#### What this PR does / why we need it:

Move `ts-tests/*` to utilize pnpm and turbo mono-repo workspace design.
With this, we managed to keep configs (eslint, prettier, babel jest)
DRY. The PR "workspace-ize" `ts-tests` but ultimately many more PR is
required to break this package into multiple smaller mono repo packages.

Follow-up PRs required to address these:

- [ ] ESLINT will be added back once we move to "testsuite", also part
of #79
- [ ] #78 

---

**What's new?**

As suggested in
#66 (comment) I've
added hardhat compile turbo workflow.

`@birthdayresearch/sticky-turbo-jest` is a turbo-aware `jest-preset`; it
automatically run `dependsOn` script before running jest. By taking
advantage of content-aware hashing from turborepo. `dependsOn` only runs
if the pipeline `inputs` has changed.

When you run your test with `@birthdayresearch/sticky-turbo-jest`
preset, it uses `displayName` from your jest config to figure out which
`pipeline` to use. It will automatically pinpoint the corresponding
`dependsOn` and run all the scripts specified within.

> TLDR, when you run a dependent test, it automatically recompiles your
contract with hardhat when it detects changes in your `contracts/*.sol`
file. If it has the cached version, it will simply "output" the result
instead of rebuilding it.

https://sticky.birthday.dev/packages/sticky-turbo-jest

`package.json`:
```json
  "scripts": {
    "compile": "hardhat compile",
    "test": "jest"
  },
  "jest": {
    "displayName": "test",
    "preset": "@birthdayresearch/sticky-turbo-jest"
  },
```

`turbo.json`:
```json
    "compile": {
      "inputs": ["contracts/**"],
      "outputs": ["artifacts", "cache"]
    },
    "test": {
      "inputs": ["src/**", "**/*.unit.ts", "tests-e2e/**"],
      "dependsOn": ["^build", "compile"]
    },
```

#### Which issue(s) does this PR fixes?:

<!--
(Optional) Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->

Fixes part of #79
canonbrother pushed a commit that referenced this issue Sep 28, 2022
…pace design (#86)

#### What this PR does / why we need it:

Move `ts-tests/*` to utilize pnpm and turbo mono-repo workspace design.
With this, we managed to keep configs (eslint, prettier, babel jest)
DRY. The PR "workspace-ize" `ts-tests` but ultimately many more PR is
required to break this package into multiple smaller mono repo packages.

Follow-up PRs required to address these:

- [ ] ESLINT will be added back once we move to "testsuite", also part
of #79
- [ ] #78 

---

**What's new?**

As suggested in
#66 (comment) I've
added hardhat compile turbo workflow.

`@birthdayresearch/sticky-turbo-jest` is a turbo-aware `jest-preset`; it
automatically run `dependsOn` script before running jest. By taking
advantage of content-aware hashing from turborepo. `dependsOn` only runs
if the pipeline `inputs` has changed.

When you run your test with `@birthdayresearch/sticky-turbo-jest`
preset, it uses `displayName` from your jest config to figure out which
`pipeline` to use. It will automatically pinpoint the corresponding
`dependsOn` and run all the scripts specified within.

> TLDR, when you run a dependent test, it automatically recompiles your
contract with hardhat when it detects changes in your `contracts/*.sol`
file. If it has the cached version, it will simply "output" the result
instead of rebuilding it.

https://sticky.birthday.dev/packages/sticky-turbo-jest

`package.json`:
```json
  "scripts": {
    "compile": "hardhat compile",
    "test": "jest"
  },
  "jest": {
    "displayName": "test",
    "preset": "@birthdayresearch/sticky-turbo-jest"
  },
```

`turbo.json`:
```json
    "compile": {
      "inputs": ["contracts/**"],
      "outputs": ["artifacts", "cache"]
    },
    "test": {
      "inputs": ["src/**", "**/*.unit.ts", "tests-e2e/**"],
      "dependsOn": ["^build", "compile"]
    },
```

#### Which issue(s) does this PR fixes?:

<!--
(Optional) Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->

Fixes part of #79
canonbrother pushed a commit that referenced this issue Sep 28, 2022
#### What this PR does / why we need it:

Refactor and move `ts-tests` into mono-repo style packages to allow
separation of context and downstream usability. This is the continuation
of #42

`@defimetachain/testcontainers`

Provides easy to use and test lightweight, throwaway instances of
MetaChain provisioned automatically in a Docker
container.

`MetaChainContainer` and `StartedMetaChainContainer` follows the
convention defined
in
[testcontainers/testcontainers-node](https://github.com/testcontainers/testcontainers-node)

```ts
let container: StartedMetaChainContainer;
let rpc: ethers.providers.JsonRpcProvider;

beforeEach(async () => {
  container = await new MetaChainContainer().start();
});

afterEach(async () => {
  await container.stop();
});

it('should createBlock', async function () {
  await container.createBlock();
  expect(await rpc.getBlockNumber()).toStrictEqual(1);
});
```


#### Which issue(s) does this PR fixes?:
<!--
(Optional) Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #78

#### Additional comments?:

The current implementation in `ts-tests` isn't yet migrated to use the
new standard and convention defined here. That should be done as part of
#79.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants