From 136b2b214536bb3a340703d3e54499d408520bae Mon Sep 17 00:00:00 2001 From: AWS CDK Automation <43080478+aws-cdk-automation@users.noreply.github.com> Date: Wed, 10 Jan 2024 07:37:44 -0800 Subject: [PATCH] chore: replace mock-fs with memfs that works in node20 (backport #355) (#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)](https://github.com/aws/jsii-rosetta/pull/355) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) --------- Co-authored-by: Momo Kornher --- test/jsii/assemblies.test.ts | 14 +++++++++----- yarn.lock | 6 +++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/test/jsii/assemblies.test.ts b/test/jsii/assemblies.test.ts index edefe1ee..62d02fdc 100644 --- a/test/jsii/assemblies.test.ts +++ b/test/jsii/assemblies.test.ts @@ -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); @@ -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( @@ -231,7 +235,7 @@ test('Backwards compatibility with literate integ tests', async () => { path.normalize('/package/test'), ); } finally { - mockfs.restore(); + unpatch(); } }); diff --git a/yarn.lock b/yarn.lock index 44248598..b7499e50 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4113,9 +4113,9 @@ text-table@^0.2.0: integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw== thingies@^1.11.1: - version "1.15.0" - resolved "https://registry.yarnpkg.com/thingies/-/thingies-1.15.0.tgz#bd186213bed5105b11eda0ce749fa475c5d4d6e3" - integrity sha512-ZSJlvEpD8QllYim0VSGlbAoob/iPrTWNlV/m8ltizMvMmzzU2gVJvHfH9ijLstyciWF70ZiQXqz+BCXWJq+ZQw== + version "1.12.0" + resolved "https://registry.yarnpkg.com/thingies/-/thingies-1.12.0.tgz#a815c224482d607aa70f563d3cbb351a338e4710" + integrity sha512-AiGqfYC1jLmJagbzQGuoZRM48JPsr9yB734a7K6wzr34NMhjUPrWSQrkF7ZBybf3yCerCL2Gcr02kMv4NmaZfA== tmpl@1.0.5: version "1.0.5"