Assert failed after update assert module
See original GitHub issueI used Jest
with AWS CDK Assert
module to test against the CDK output just like example.
It was fine when I have @aws/cdk/assert 1.13.1
or the lower version installed.
But after update @aws/cdk/assert
to 1.14.0
or 1.15.0
, all tests always failed with:
None of 0 resources matches resource ...
.
If I reinstalled @aws/cdk/assert 1.13.1
, the tests will pass again.
The output of cdk synth
& deployment is good though.
Is there a possibility of regression from upgrading 1.13.1
to 1.14.0
?
Reproduction Steps
with @aws/cdk/assert
1.14.0
or 1.15.0
class SampleStack extends cdk.Stack {
constructor(scope, id, props) {
super(scope, id, props);
new events.Rule(this, 'timer', {
description: 'Execute every 5 min',
schedule: events.Schedule.rate(cdk.Duration.minutes(5)),
});
}
}
module.exports = SampleStack;
const { expect: expectCDK, haveResource } = require('@aws-cdk/assert');
...
test('Event Created', () => {
const app = new cdk.App();
const stack = new SampleStack(app, 'testStack');
expectCDK(stack).to(haveResource('AWS::Events::Rule'));
});
Error Log
None of 0 resources matches resource 'AWS::Events::Rule' with properties undefined.
at HaveResourceAssertion.assertOrThrow (node_modules/@aws-cdk/assert/lib/assertions/have-resource.ts:83:13)
at StackInspector._to (node_modules/@aws-cdk/assert/lib/inspector.ts:25:15)
at StackInspector.to (node_modules/@aws-cdk/assert/lib/inspector.ts:15:25)
at Object.to (test/stack.test.js:16:20)
Environment
- CLI Version :
1.15.0
- Framework Version:
1.15.0
- OS :
macOS
- Language :
Node.js 12.13.0
Other
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Assert | Node.js v19.3.0 Documentation
Indicates the failure of an assertion. All errors thrown by the node:assert module will be instances of the AssertionError class. new assert.AssertionError( ...
Read more >Node.js assert.fail() Function - GeeksforGeeks
The assert. fail() function throws an AssertionError with the provided the error message or with a default error message.
Read more >FIX: An assertion failure occurs when you repeatedly plug in ...
File name File size Date Time Path
Ndislib.lib 6,423,076 02‑Oct‑2012 17:20 Public\Common\Oak\Lib\Armv5\Checked
Ndislib.lib 7,259,688 02‑Oct‑2012 17:20 Public\Common\Oak\Lib\Armv5\Debug
Ndislib.lib 5,460,216 02‑Oct‑2012 17:19 Public\Common\Oak\Lib\Armv5\Retail
Read more >Node.js Assert Module - W3Schools
The assert module provides a way of testing expressions. If the expression evaluates to 0, or false, an assertion failure is being caused,...
Read more >ansible.builtin.assert module – Asserts given expressions are ...
In most cases, you can use the short module name assert even without ... 3 - name: After version 2.7 both 'msg' and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @RomainMuller ,
After removing
node_modules
&package-lock.json
, reinstalled all@aws-cdk
packages with version1.15.0
, the assertion is working as expected again!Yes, I think it is the case. somehow the upgrade procedure was messed up. Thanks for the heads up!
I guess you may have been bit by having multiple different (possibly incompatible) versions of the
@aws-cdk/*
libraries in your closure, which can cause unexpected behavior.Can you comment as to whether this could have been the case?