diff --git a/.projen/deps.json b/.projen/deps.json index 32d6920..8488848 100644 --- a/.projen/deps.json +++ b/.projen/deps.json @@ -90,6 +90,10 @@ "version": "~5.0.0", "type": "build" }, + { + "name": "mock-fs", + "type": "build" + }, { "name": "prettier", "type": "build" @@ -127,10 +131,6 @@ "name": "constructs", "type": "bundled" }, - { - "name": "mock-fs", - "type": "bundled" - }, { "name": "uuid", "type": "bundled" diff --git a/.projenrc.ts b/.projenrc.ts index 0a36314..8915283 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -76,10 +76,9 @@ const buildOptions: Pick< const projenDevDeps = ['projen@0.72.23', 'publib', '@types/uuid']; const projenDeps = ['uuid', 'cdktf', 'constructs', 'yaml']; -const jestDeps = ['mock-fs']; -const jestDevDeps = ['@swc/jest', '@swc/core', 'jest-junit', '@types/mock-fs']; +const jestDevDeps = ['@swc/jest', '@swc/core', 'jest-junit', '@types/mock-fs', 'mock-fs']; -const bundledDeps = ([] as string[]).concat(projenDeps, jestDeps); +const bundledDeps = ([] as string[]).concat(projenDeps); const devDeps = ([] as string[]).concat(projenDevDeps, jestDevDeps); const peerDeps = ([] as string[]).concat('projen'); @@ -160,9 +159,9 @@ const testOptions: TestOptions = { clearMocks: true, coverageProvider: 'v8', moduleFileExtensions: ['ts', 'js', 'json', 'node'], - setupFilesAfterEnv: ['/src/setupJest.js'], + setupFilesAfterEnv: ['/test/setupJest.js'], testEnvironment: 'node', - testMatch: ['src/**/test/*.ts'], + testMatch: ['test/**/*.test.ts'], testPathIgnorePatterns: ['/node_modules/', '.d.ts', '.js'], transform: { '\\.[jt]sx?$': new Transform('@swc/jest'), diff --git a/package.json b/package.json index ab1c26e..47efcee 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ "jsii-docgen": "^10.0.0", "jsii-pacmak": "^1.87.0", "jsii-rosetta": "~5.0.0", + "mock-fs": "^5.2.0", "prettier": "^3.0.2", "projen": "0.72.23", "publib": "^0.2.737", @@ -71,14 +72,12 @@ "dependencies": { "cdktf": "^0.19.0", "constructs": "^10.3.0", - "mock-fs": "^5.2.0", "uuid": "^9.0.0", "yaml": "^2.3.2" }, "bundledDependencies": [ "cdktf", "constructs", - "mock-fs", "uuid", "yaml" ], @@ -99,11 +98,11 @@ "node" ], "setupFilesAfterEnv": [ - "/src/setupJest.js" + "/test/setupJest.js" ], "testEnvironment": "node", "testMatch": [ - "src/**/test/*.ts", + "test/**/*.test.ts", "/src/**/__tests__/**/*.ts?(x)", "/(test|src)/**/*(*.)@(spec|test).ts?(x)" ], diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9f0f060..0c31f46 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,9 +11,6 @@ dependencies: constructs: specifier: ^10.3.0 version: 10.3.0 - mock-fs: - specifier: ^5.2.0 - version: 5.2.0 uuid: specifier: ^9.0.0 version: 9.0.1 @@ -85,6 +82,9 @@ devDependencies: jsii-rosetta: specifier: ~5.0.0 version: 5.0.28 + mock-fs: + specifier: ^5.2.0 + version: 5.2.0 prettier: specifier: ^3.0.2 version: 3.1.1 @@ -5370,7 +5370,7 @@ packages: /mock-fs@5.2.0: resolution: {integrity: sha512-2dF2R6YMSZbpip1V1WHKGLNjr/k48uQClqMVb5H3MOvwc9qhYis3/IWbj02qIg/Y8MDXKFF4c5v0rxx2o6xTZw==} engines: {node: '>=12.0.0'} - dev: false + dev: true /modify-values@1.0.1: resolution: {integrity: sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw==} diff --git a/src/test/CdktfConfig.test.ts b/test/CdktfConfig.test.ts similarity index 99% rename from src/test/CdktfConfig.test.ts rename to test/CdktfConfig.test.ts index 90f2b8d..7457961 100644 --- a/src/test/CdktfConfig.test.ts +++ b/test/CdktfConfig.test.ts @@ -1,7 +1,7 @@ import * as path from 'path'; import mockfs from 'mock-fs'; import { TestProject } from './TestProject'; -import { CdktfConfig, Language, RequirementDefinition } from '../CdktfConfig'; +import { CdktfConfig, Language, RequirementDefinition } from '../src/CdktfConfig'; describe('CdktfConfig', () => { describe('cdktfVersion', () => { @@ -67,7 +67,7 @@ describe('CdktfConfig', () => { // 'node_modules/.pnpm/projen@0.72.23/node_modules/projen/license-text/Apache-2.0.txt': mockfs.load( // path.resolve(__dirname, '../../node_modules/projen/license-text/Apache-2.0.txt') // ), - [licenseFilePath]: mockfs.load(path.resolve(__dirname, `../../node_modules/projen/${licenseRelativePath}`)), + [licenseFilePath]: mockfs.load(path.resolve(__dirname, `../node_modules/projen/${licenseRelativePath}`)), 'cdktf.json': mockfs.load(path.resolve(__dirname, 'cdktf.fixture.json')), }); diff --git a/src/test/CdktfTypescriptApp.test.ts b/test/CdktfTypescriptApp.test.ts similarity index 95% rename from src/test/CdktfTypescriptApp.test.ts rename to test/CdktfTypescriptApp.test.ts index f6886c1..b2a1d64 100644 --- a/src/test/CdktfTypescriptApp.test.ts +++ b/test/CdktfTypescriptApp.test.ts @@ -1,5 +1,5 @@ -import { Language } from '../CdktfConfig'; -import { CdktfTypeScriptApp } from '../CdktfTypescriptApp'; +import { Language } from '../src/CdktfConfig'; +import { CdktfTypeScriptApp } from '../src/CdktfTypescriptApp'; describe('CdktfApp', () => { describe('app', () => { diff --git a/src/test/TestProject.ts b/test/TestProject.ts similarity index 100% rename from src/test/TestProject.ts rename to test/TestProject.ts diff --git a/src/test/cdktf.fixture.json b/test/cdktf.fixture.json similarity index 96% rename from src/test/cdktf.fixture.json rename to test/cdktf.fixture.json index ab53c67..b2d1476 100644 --- a/src/test/cdktf.fixture.json +++ b/test/cdktf.fixture.json @@ -1,8 +1,8 @@ -{ - "app": "npx ts-node main.ts", - "language": "typescript", - "projectId": "12345678-1234-1234-1234-123456789012", - "sendCrashReports": "false", - "terraformProviders": [], - "terraformModules": [] -} +{ + "app": "npx ts-node main.ts", + "language": "typescript", + "projectId": "12345678-1234-1234-1234-123456789012", + "sendCrashReports": "false", + "terraformProviders": [], + "terraformModules": [] +} diff --git a/src/setupJest.js b/test/setupJest.js similarity index 94% rename from src/setupJest.js rename to test/setupJest.js index c8cff6d..7bd73c0 100644 --- a/src/setupJest.js +++ b/test/setupJest.js @@ -1,3 +1,3 @@ -import { Testing } from 'cdktf'; - -Testing.setupJest(); +import { Testing } from 'cdktf'; + +Testing.setupJest();