Skip to content

Commit

Permalink
chore: replace mock-fs with memfs that works in node20 (backport #355) (
Browse files Browse the repository at this point in the history
#641)

# Backport

This will backport the following commits from `main` to
`maintenance/v5.0`:
- [chore: replace mock-fs with memfs that works in node20
(#355)](#355)

<!--- Backport version: 9.3.0 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

---------

Co-authored-by: Momo Kornher <[email protected]>
  • Loading branch information
aws-cdk-automation and mrgrain authored Jan 10, 2024
1 parent d070e04 commit 136b2b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 9 additions & 5 deletions test/jsii/assemblies.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { promises as fs } from 'node:fs';
import * as path from 'node:path';
import * as spec from '@jsii/spec';
import * as mockfs from 'mock-fs';
import { Volume } from 'memfs';

import { fakeAssembly } from './fake-assembly';
import { allTypeScriptSnippets } from '../../lib/jsii/assemblies';
import { SnippetParameters } from '../../lib/snippet';
import { TestJsiiModule, DUMMY_JSII_CONFIG } from '../testutil';
// eslint-disable-next-line @typescript-eslint/no-require-imports
const { patchFs } = require('fs-monkey');

jest.setTimeout(30_000);

Expand Down Expand Up @@ -201,9 +203,11 @@ test('Fixture allows use of import statements', async () => {
});

test('Backwards compatibility with literate integ tests', async () => {
mockfs({
'/package/test/integ.example.lit.ts': '# Some literate source file',
});
const unpatch = patchFs(
Volume.fromJSON({
'/package/test/integ.example.lit.ts': '# Some literate source file',
}),
);

try {
const snippets = Array.from(
Expand Down Expand Up @@ -231,7 +235,7 @@ test('Backwards compatibility with literate integ tests', async () => {
path.normalize('/package/test'),
);
} finally {
mockfs.restore();
unpatch();
}
});

Expand Down
6 changes: 3 additions & 3 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 136b2b2

Please sign in to comment.