Skip to content

Commit

Permalink
* Skip slow tests when building in DEBUG mode.
Browse files Browse the repository at this point in the history
* Change "module" and "moduleResolution" typescript options when bundling for browsers.
  • Loading branch information
cowwoc committed Nov 30, 2023
1 parent 036b6ed commit 36115ca
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 9 deletions.
15 changes: 8 additions & 7 deletions build.mts
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,21 @@ class Build
public async compileForBrowser()
{
log.info("compileForBrowser()");
// WORKAROUND: https://github.com/algolia/algoliasearch-client-javascript/issues/1431#issuecomment-1568529321
const commonJsToEsm = (rollupCommonjs as unknown as (typeof rollupCommonjs)["default"]);
const typescriptPlugin = (rollupTypescript as unknown as (typeof rollupTypescript)["default"]);

// See https://github.com/gulpjs/gulp/blob/master/docs/recipes/rollup-with-rollup-stream.md
// Need to cast plugins to Function due to bug in type definitions.
// WORKAROUND: https://github.com/algolia/algoliasearch-client-javascript/issues/1431#issuecomment-1568529321
const plugins: Plugin[] = [
commonJsToEsm,
typescriptPlugin(),
rollupCommonjs,
(rollupTypescript as unknown as Function)({
"module": "ES2022",
"moduleResolution": "bundler"
}),
rollupNodeResolve(
{
mainFields: ["module"],
preferBuiltins: true
}),
commonJsToEsm({include: "node_modules/**"})
(rollupCommonjs as unknown as Function)({include: "node_modules/**"})
];

const bundle = await rollup(
Expand Down
28 changes: 27 additions & 1 deletion test/BooleanTest.mts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@ import {
import {TestGlobalConfiguration} from "./TestGlobalConfiguration.mjs";
import {TestCompiler} from "./TestCompiler.mjs";
import os from "os";
import parseArgs from "minimist";

const globalConfiguration = new TestGlobalConfiguration(TerminalEncoding.NONE);
const configuration = new Configuration(globalConfiguration);
const requirements = new Requirements(configuration);
const compiler = new TestCompiler();

const env = parseArgs(process.argv.slice(2));
let mode = env.mode;
if (typeof (mode) === "undefined")
mode = "DEBUG";
let compiler: TestCompiler | undefined;
if (mode === "DEBUG")
compiler = undefined;
else
compiler = new TestCompiler();

suite("BooleanTest", () =>
{
Expand Down Expand Up @@ -57,6 +67,8 @@ suite("BooleanTest", () =>

test("nullAsBoolean", () =>
{
if (!compiler)
return;
const code =
`import {requireThat} from "./target/publish/node/index.mjs";
Expand All @@ -69,6 +81,8 @@ suite("BooleanTest", () =>

test("zeroNumberAsBoolean", () =>
{
if (!compiler)
return;
const code =
`import {requireThat} from "./target/publish/node/index.mjs";
Expand All @@ -81,6 +95,8 @@ suite("BooleanTest", () =>

test("nonZeroNumberAsBoolean", () =>
{
if (!compiler)
return;
const code =
`import {requireThat} from "./target/publish/node/index.mjs";
Expand All @@ -93,6 +109,8 @@ suite("BooleanTest", () =>

test("zeroStringAsBoolean", () =>
{
if (!compiler)
return;
const code =
`import {requireThat} from "./target/publish/node/index.mjs";
Expand All @@ -105,6 +123,8 @@ suite("BooleanTest", () =>

test("nonZeroStringAsBoolean", () =>
{
if (!compiler)
return;
const code =
`import {requireThat} from "./target/publish/node/index.mjs";
Expand All @@ -117,6 +137,8 @@ suite("BooleanTest", () =>

test("trueStringAsBoolean", () =>
{
if (!compiler)
return;
const code =
`import {requireThat} from "./target/publish/node/index.mjs";
Expand All @@ -129,6 +151,8 @@ suite("BooleanTest", () =>

test("emptyStringAsBoolean", () =>
{
if (!compiler)
return;
const code =
`import {requireThat} from "./target/publish/node/index.mjs";
Expand All @@ -141,6 +165,8 @@ suite("BooleanTest", () =>

test("falseStringAsBoolean", () =>
{
if (!compiler)
return;
const code =
`import {requireThat} from "./target/publish/node/index.mjs";
Expand Down
18 changes: 17 additions & 1 deletion test/ObjectTest.mts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,22 @@ import {Requirements} from "../src/index.mjs";
import {TestCompiler} from "./TestCompiler.mjs";
import {TestGlobalConfiguration} from "./TestGlobalConfiguration.mjs";
import * as os from "os";
import parseArgs from "minimist";


const globalConfiguration = new TestGlobalConfiguration(TerminalEncoding.NONE);
const configuration = new Configuration(globalConfiguration);
const requirements = new Requirements(configuration);
const compiler = new TestCompiler();

const env = parseArgs(process.argv.slice(2));
let mode = env.mode;
if (typeof (mode) === "undefined")
mode = "DEBUG";
let compiler: TestCompiler | undefined;
if (mode === "DEBUG")
compiler = undefined;
else
compiler = new TestCompiler();

suite("ObjectTest", () =>
{
Expand Down Expand Up @@ -76,6 +86,8 @@ suite("ObjectTest", () =>

test("isEqual_sameToStringDifferentTypes", () =>
{
if (!compiler)
return;
const code =
`import {requireThat} from "./target/publish/node/index.mjs";
Expand All @@ -94,6 +106,8 @@ suite("ObjectTest", () =>

test("isEqualTo_nullToNotNull", () =>
{
if (!compiler)
return;
const code =
`import {requireThat} from "./target/publish/node/index.mjs";
Expand All @@ -106,6 +120,8 @@ suite("ObjectTest", () =>

test("isEqualTo_notNullToNull", () =>
{
if (!compiler)
return;
const code =
`import {requireThat} from "./target/publish/node/index.mjs";
Expand Down

0 comments on commit 36115ca

Please sign in to comment.