Skip to content

Commit

Permalink
Use installPackages options object in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
georgestagg committed Oct 25, 2023
1 parent a07a271 commit 17aca61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/tests/packages/webr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async function evalTest(pkg: string) {
beforeAll(async () => {
await webR.init();
// Install packages required to run all package examples and tests
await webR.installPackages(['Matrix', 'MASS'], true);
await webR.installPackages(['Matrix', 'MASS'], { quiet: true });
});

test('The webr R package is installed', async () => {
Expand Down
10 changes: 7 additions & 3 deletions src/tests/webR/webr-worker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,26 @@ beforeAll(async () => {
describe('Download and install binary webR packages', () => {
test('Install packages via evalR', async () => {
const warnSpy = jest.spyOn(console, 'warn').mockImplementation((...args) => {});
await webR.evalR('webr::install("cli", repos="https://repo.r-wasm.org/")');
await webR.evalR(
'webr::install("cli", repos="https://repo.r-wasm.org/", mount = FALSE)'
);
const pkg = (await webR.evalR('"cli" %in% library(cli)')) as RLogical;
expect(await pkg.toBoolean()).toEqual(true);
warnSpy.mockRestore();
});

test('Install packages quietly', async () => {
const warnSpy = jest.spyOn(console, 'warn').mockImplementation((...args) => {});
await webR.evalR('webr::install("Matrix", repos="https://repo.r-wasm.org/", quiet=TRUE)');
await webR.evalR(
'webr::install("Matrix", repos="https://repo.r-wasm.org/", mount = FALSE, quiet = TRUE)'
);
expect(warnSpy).not.toHaveBeenCalled();
warnSpy.mockRestore();
});

test('Install packages via API', async () => {
const warnSpy = jest.spyOn(console, 'warn').mockImplementation((...args) => {});
await webR.installPackages(['MASS']);
await webR.installPackages(['MASS'], { mount: false });
const pkg = (await webR.evalR('"MASS" %in% library(MASS)')) as RLogical;
expect(await pkg.toBoolean()).toEqual(true);
warnSpy.mockRestore();
Expand Down

0 comments on commit 17aca61

Please sign in to comment.