allure-vitest
Version:
Allure Vitest integration
65 lines • 2.42 kB
JavaScript
import { BaseVitestTestRuntime } from "./runtime.js";
const toBufferContent = (content, encoding) => typeof content === "string"
? Buffer.from(content, encoding)
: content instanceof Uint8Array
? Buffer.from(content)
: content;
export class VitestTestRuntime extends BaseVitestTestRuntime {
async attachment(name, content, options) {
const bufferContent = toBufferContent(content, options.encoding);
await this.sendMessage({
type: "attachment_content",
data: {
name,
content: bufferContent.toString("base64"),
encoding: "base64",
contentType: options.contentType,
fileExtension: options.fileExtension,
wrapInStep: true,
timestamp: Date.now(),
},
});
}
async globalAttachment(name, content, options) {
const bufferContent = toBufferContent(content, options.encoding);
await this.sendMessage({
type: "global_attachment_content",
data: {
name,
content: bufferContent.toString("base64"),
encoding: "base64",
contentType: options.contentType,
fileExtension: options.fileExtension,
},
});
}
syncAttachment(sendMessageSync, name, content, options) {
const bufferContent = toBufferContent(content, options.encoding);
sendMessageSync({
type: "attachment_content",
data: {
name,
content: bufferContent.toString("base64"),
encoding: "base64",
contentType: options.contentType,
fileExtension: options.fileExtension,
wrapInStep: true,
timestamp: Date.now(),
},
});
}
syncGlobalAttachment(sendMessageSync, name, content, options) {
const bufferContent = toBufferContent(content, options.encoding);
sendMessageSync({
type: "global_attachment_content",
data: {
name,
content: bufferContent.toString("base64"),
encoding: "base64",
contentType: options.contentType,
fileExtension: options.fileExtension,
},
});
}
}
//# sourceMappingURL=VitestTestRuntime.js.map