Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: ensure declarationMap sources are correct #403

Merged
merged 1 commit into from
Aug 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions __tests__/integration/no-errors.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { jest, afterAll, test, expect } from "@jest/globals";
import * as path from "path";
import * as fs from "fs-extra";
import { OutputAsset } from "rollup";
import { normalizePath as normalize } from "@rollup/pluginutils";

import { RPT2Options } from "../../src/index";
import * as helpers from "./helpers";
Expand All @@ -10,13 +12,14 @@ jest.setTimeout(15000);

const local = (x: string) => path.resolve(__dirname, x);
const testDir = local("__temp/no-errors");
const fixtureDir = local("fixtures/no-errors");

afterAll(() => fs.remove(testDir));

async function genBundle(relInput: string, extraOpts?: RPT2Options) {
return helpers.genBundle({
input: local(`fixtures/no-errors/${relInput}`),
tsconfig: local("fixtures/no-errors/tsconfig.json"),
input: `${fixtureDir}/${relInput}`,
tsconfig: `${fixtureDir}/tsconfig.json`,
testDir,
extraOpts,
});
Expand All @@ -41,6 +44,11 @@ test("integration - no errors", async () => {

// JS file should be bundled by Rollup, even though rpt2 does not resolve it (as Rollup natively understands ESM)
expect(output[0].code).toEqual(expect.stringContaining("identity"));

// declaration map sources should be correctly remapped (and not point to placeholder dir, c.f. https://github.com/ezolenko/rollup-plugin-typescript2/pull/221)
const decMapSources = JSON.parse((output[2] as OutputAsset).source as string).sources;
const decRelPath = normalize(path.relative(`${testDir}/dist`, `${fixtureDir}/index.ts`));
expect(decMapSources).toEqual([decRelPath]);
});

test("integration - no errors - no declaration maps", async () => {
Expand Down