|
| 1 | +/** |
| 2 | + * Unit tests that depend on 'aws-cdk-lib' having been compiled using jsii |
| 3 | + */ |
1 | 4 | import * as fs from 'fs';
|
2 | 5 | import * as path from 'path';
|
3 | 6 | import { Construct } from 'constructs';
|
4 |
| -import { App, NestedStack, Stack, Stage, IPolicyValidationPluginBeta1, PolicyViolationBeta1, PolicyValidationPluginReportBeta1, IPolicyValidationContextBeta1 } from '../lib'; |
5 |
| -import { constructInfoFromConstruct, constructInfoFromStack } from '../lib/private/runtime-info'; |
| 7 | +import { App, NestedStack, Stack, Stage, IPolicyValidationPluginBeta1, PolicyViolationBeta1, PolicyValidationPluginReportBeta1, IPolicyValidationContextBeta1 } from 'aws-cdk-lib'; |
| 8 | +import { constructInfoFromConstruct, constructInfoFromStack } from 'aws-cdk-lib/core/lib/helpers-internal'; |
6 | 9 |
|
7 | 10 | const JSII_RUNTIME_SYMBOL = Symbol.for('jsii.rtti');
|
8 | 11 |
|
9 | 12 | let app: App;
|
10 | 13 | let stack: Stack;
|
11 | 14 | let _cdkVersion: string | undefined = undefined;
|
12 | 15 |
|
13 |
| -// The runtime metadata this test relies on is only available if the most |
14 |
| -// recent compile has happened using 'jsii', as the jsii compiler injects |
15 |
| -// this metadata. |
16 |
| -// |
17 |
| -// If the most recent compile was using 'tsc', the metadata will not have |
18 |
| -// been injected, and the test suite will fail. |
19 |
| -// |
20 |
| -// Tolerate `tsc` builds locally, but not on CodeBuild. |
21 |
| -const codeBuild = !!process.env.CODEBUILD_BUILD_ID; |
22 |
| -const moduleCompiledWithTsc = constructInfoFromConstruct(new Stack())?.fqn === 'constructs.Construct'; |
23 |
| -let describeTscSafe = describe; |
24 |
| -if (moduleCompiledWithTsc && !codeBuild) { |
25 |
| - // eslint-disable-next-line |
26 |
| - console.error('It appears this module was compiled with `tsc` instead of `jsii` in a local build. Skipping this test suite.'); |
27 |
| - describeTscSafe = describe.skip; |
28 |
| -} |
29 |
| - |
30 | 16 | beforeEach(() => {
|
31 | 17 | app = new App();
|
32 | 18 | stack = new Stack(app, 'Stack', {
|
33 | 19 | analyticsReporting: true,
|
34 | 20 | });
|
35 | 21 | });
|
36 | 22 |
|
37 |
| -describeTscSafe('constructInfoFromConstruct', () => { |
| 23 | +describe('constructInfoFromConstruct', () => { |
38 | 24 | test('returns fqn and version for core constructs', () => {
|
39 | 25 | const constructInfo = constructInfoFromConstruct(stack);
|
40 | 26 | expect(constructInfo).toBeDefined();
|
@@ -70,7 +56,7 @@ describeTscSafe('constructInfoFromConstruct', () => {
|
70 | 56 | });
|
71 | 57 | });
|
72 | 58 |
|
73 |
| -describeTscSafe('constructInfoForStack', () => { |
| 59 | +describe('constructInfoForStack', () => { |
74 | 60 | test('returns stack itself and jsii runtime if stack is empty', () => {
|
75 | 61 | const constructInfos = constructInfoFromStack(stack);
|
76 | 62 |
|
|
0 commit comments