Skip to content

Commit

Permalink
simplify integration test folder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushik-rishi committed Oct 2, 2023
1 parent 0dea140 commit 5afd14e
Show file tree
Hide file tree
Showing 61 changed files with 66 additions and 5,498 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"homepage": "https://github.com/asyncapi/nodejs-template#readme",
"scripts": {
"test": "rimraf test/temp && jest --modulePathIgnorePatterns='./template'",
"test": "rimraf test/temp && jest --forceExit --modulePathIgnorePatterns='./template'",
"test:updateSnapshot": "rimraf test/temp && jest --updateSnapshot --modulePathIgnorePatterns='./template'",
"lint": "eslint --max-warnings 0 --config .eslintrc .",
"lint:fix": "eslint --fix --config .eslintrc .",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const receiveLightMeasurementMiddlewares = [];
* @throws {TypeError} If middlewareFn is not a function.
*/
handler.registerReceiveLightMeasurementMiddleware = (middlewareFn) => {
console.log("registering middleware");
if (typeof middlewareFn !== 'function') {
throw new TypeError('middlewareFn must be a function');
}
Expand Down

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

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"config": {
"example_name": "mqtt/publish",
"root_dir": "../../../.."
"example_name": "mqtt",
"root_dir": "../../.."
},
"scripts": {
"setup": "npm run generate:client && npm install",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function waitForMessage() {
*/
async function setupSubscribe() {
const mqtt = require('mqtt');
const client = mqtt.connect(brokerUrl);
const client = mqtt.connect(BROKER_URL);

return new Promise((resolve, reject) => {
const topic = TURN_ON_TOPIC;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ const {
setupSubscribe,
setupPublishMiddleware,
setupPublish,
} = require('./index');
} = require('./publish-utils');

// Mocking the console.debug function to prevent console output during testing
jest.spyOn(global.console, 'debug').mockImplementation(() => {
return;
});
const consoleDebugSpy = jest.spyOn(global.console, 'debug');

describe('MQTT Connection Setup and Message Processing', () => {
describe('[PUBLISH] MQTT Connection Setup and Message Processing', () => {
jest.setTimeout(10000);

beforeAll(() => {
Expand Down Expand Up @@ -41,8 +41,7 @@ describe('MQTT Connection Setup and Message Processing', () => {

// Parsing and comparing the received JSON payload
const jsonMessage = JSON.stringify(JSON.parse(message));
console.log('bois the json message is ', jsonMessage);

expect(jsonMessage).toBe('{"command":"on"}');
});
});

Loading

0 comments on commit 5afd14e

Please sign in to comment.