diff --git a/lib/podlet.js b/lib/podlet.js index 0225ee33..87d8509a 100644 --- a/lib/podlet.js +++ b/lib/podlet.js @@ -903,7 +903,7 @@ export default class PodiumPodlet { */ middleware() { return async (req, res, next) => { - const incoming = new HttpIncoming(req, res); + const incoming = new HttpIncoming(req, res, res.locals); // @ts-ignore incoming.url = new URL( req.originalUrl, diff --git a/package.json b/package.json index 28be3031..3dfdda54 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "eslint-plugin-import": "2.29.1", "eslint-plugin-prettier": "5.1.3", "express": "4.19.2", + "json-stringify-safe": "5.0.1", "prettier": "3.2.4", "semantic-release": "23.0.6", "tap": "18.7.2", diff --git a/tests/podlet.js b/tests/podlet.js index 4daf083d..99d6d148 100644 --- a/tests/podlet.js +++ b/tests/podlet.js @@ -1,11 +1,13 @@ // @ts-nocheck +/* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable no-unused-expressions */ /* eslint-disable max-classes-per-file */ /* eslint-disable no-param-reassign */ import { destinationObjectStream } from '@podium/test-utils'; import { template, HttpIncoming, AssetJs, AssetCss } from '@podium/utils'; +import stringify from 'json-stringify-safe'; import { join, dirname } from 'path'; import Metrics from '@metrics/client'; import tap from 'tap'; @@ -120,7 +122,7 @@ class FakeExpressServer { this.app.use( onRequest || ((req, res) => { - res.status(200).json(res.locals); + res.status(200).send(stringify(res.locals)); }), ); this.server = undefined; @@ -1303,6 +1305,24 @@ tap.test('.view() - append a custom wireframe document - should render developme await server.close(); }); +tap.test('.view() - append a custom wireframe document - should render development output with custom wireframe document', async (t) => { + const options = { ...DEFAULT_OPTIONS, development: true }; + + const podlet = new Podlet(options); + podlet.view((incoming, data) => `