3.3.0 • Published 12 days ago

reveal-test v3.3.0

Weekly downloads
53
License
MIT
Repository
github
Last release
12 days ago

reveal-test

npm version npm publish

Utilities for testing presentation code snippets by compiling them on Compiler Explorer.

Check out also reveal-compiler-explorer package.

Example

const { parseMarkdown, compile, CompileError } = require('reveal-test');

const codeInfos = await parseMarkdown('presentation.md');

describe("demo presentation", function () {
  codeInfo.forEach((info, index) => {
    it(`should have snippet ${index} compiled`, async function () {
      await compile(info);
    });
  });
}, 10000);

For reference, take a look at the demo package in this repo.


Installation

npm install --save-dev reveal-test

or

yarn add -D reveal-test

API

parseMarkdown

parseMarkdown(path: String, config: Config = {}) => Promise<Array<SnippetInfo>>

Asynchronously generates a list of all code snippets from a given markdown file. For possible config fields, see here.

compile

compile(info: SnippetInfo) => String

Calls CE's Rest API to compile a code snippet.

Returns output from compiling and running the code (if enabled) on success, otherwise throws CompileError with code being the exit code and message being the compiler's error message.


Directives

In addition to the directives mentioned here, the following directives are supported:

///fails=<reason>

When given, compile will fail if compiling and running the code (if enabled) succeeds, or if the error message doesn't include the given reason.

Cannot be defined together with output.

Usage example:

///fails=expected ';' before '}' token
#include <iostream>

int main() {
  std::cout << "Hello CE!"
}

///output=<expected>

When given, compile will fail if the snippet's output doesn't include the given output.

Cannot be defined together with fails.

Usage example:

///external
///output=Hello CE!
#include <iostream>

int main() {
  std::cout << "Hello CE!";
}
3.3.0

12 days ago

3.2.1

18 days ago

3.1.0

1 year ago

3.0.0

2 years ago

2.1.3

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.3.4

3 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.2

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago