Skip to content

Commit

Permalink
fix: 🐛 fixed the failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
WasiqB committed Sep 9, 2024
1 parent e9b60b7 commit f601ab1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions examples/cypress/pnpm-lock.yaml

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"release.patch": "pnpm release.ci patch",
"release.minor": "pnpm release.ci minor",
"release.major": "pnpm release.ci major",
"build": "rm -rf dist && tsc",
"build": "rm -rf dist && tsc && cp -R src/templates dist/templates",
"dev": "pnpm build -w",
"test": "node ./test/test.js",
"new:test": "pnpm node ./src/test/dummy/test.mjs",
"new:test": "pnpm node ./src/test/test.mjs",
"new:unit:test": "pnpm node src/runner.mjs",
"new:unit:coverage": "nyc pnpm new:unit:test",
"unit.test": "jasmine JASMINE_CONFIG_PATH=test/unit/jasmine.json",
Expand Down
6 changes: 4 additions & 2 deletions src/generate-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,11 @@ const parseSteps = (

switch (type) {
case "application/json":
const content = Buffer.from(data, "base64").toString();
embedding.data = Buffer.from(data, "base64").toString();
step.json = (step.json || []).concat([
typeof content === "string" ? JSON.parse(content) : content,
typeof embedding.data === "string"
? JSON.parse(embedding.data)
: embedding.data,
]);
break;
case "text/html":
Expand Down
5 changes: 4 additions & 1 deletion src/test/dummy/test.mjs → src/test/test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import path from "node:path";
import { generateReport } from "../../../dist/generate-report.js";
import { generateReport } from "../../dist/generate-report.js";
import { getCurrentDir } from "../../dist/utils/constants.js";

const __dirname = getCurrentDir(import.meta.url);

/**
* Generate a report for browsers
Expand Down
11 changes: 4 additions & 7 deletions src/utils/template.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import fs from "fs-extra";
import path from "path";
import _ from "lodash";
import { Options, Suite } from "../types/report-types";
import { Options, Suite } from "../types/report-types.js";
import { getCurrentDir } from "./constants.js";

const __dirname = getCurrentDir(import.meta.url);
const dirname = getCurrentDir(import.meta.url);

const GENERIC_JS = "generic.js";
const INDEX_HTML = "index.html";
Expand Down Expand Up @@ -38,7 +38,7 @@ const _readTemplateFile = (fileName: string): string => {
return fs.readFileSync(fileName, "utf-8");
} catch (err) {
return fs.readFileSync(
path.join(__dirname, "..", "templates", fileName),
path.join(dirname, "..", "templates", fileName),
"utf-8"
);
}
Expand Down Expand Up @@ -173,10 +173,7 @@ const _createFeatureIndexPages = (
const assetsPath = path.resolve(reportPath || "", "assets");

if (!fs.pathExistsSync(assetsPath) && !suite.useCDN) {
fs.copySync(
path.join(__dirname, "..", "templates", "assets"),
assetsPath
);
fs.copySync(path.join(dirname, "..", "templates", "assets"), assetsPath);
}
});
};
Expand Down

0 comments on commit f601ab1

Please sign in to comment.