Skip to content

Commit

Permalink
test(flat-routes): do not depend on config internals
Browse files Browse the repository at this point in the history
  • Loading branch information
pcattori committed Jun 13, 2023
1 parent 7db7c4c commit e9d1b47
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 32 deletions.
7 changes: 4 additions & 3 deletions integration/flat-routes-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { PlaywrightFixture } from "./helpers/playwright-fixture";
import type { Fixture, AppFixture } from "./helpers/create-fixture";
import { createFixtureProject } from "./helpers/create-fixture";
import { createAppFixture, createFixture, js } from "./helpers/create-fixture";
import { flatRoutesWarning } from "../packages/remix-dev/config";

let fixture: Fixture;
let appFixture: AppFixture;
Expand Down Expand Up @@ -159,7 +158,7 @@ test.describe("flat routes", () => {
});
}

test("allows ignoredRouteFiles to be configured", async ({ page }) => {
test("allows ignoredRouteFiles to be configured", async () => {
let routeIds = Object.keys(fixture.build.routes);

expect(routeIds).not.toContain(IGNORED_ROUTE);
Expand Down Expand Up @@ -210,7 +209,9 @@ test.describe("warns when v1 routesConvention is used", () => {

test("v2_routeConvention is not enabled", () => {
console.log(buildOutput);
expect(buildOutput).toContain(flatRoutesWarning);
expect(buildOutput).toContain(
"The route file convention is changing in v2"
);
});
});

Expand Down
24 changes: 2 additions & 22 deletions packages/remix-dev/__tests__/create-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ import stripAnsi from "strip-ansi";

import { run } from "../cli/run";
import { server } from "./msw";
import {
errorBoundaryWarning,
flatRoutesWarning,
formMethodWarning,
headersWarning,
metaWarning,
serverModuleFormatWarning,
} from "../config";

beforeAll(() => server.listen({ onUnhandledRequest: "error" }));
afterAll(() => server.close());
Expand Down Expand Up @@ -354,20 +346,8 @@ describe("the create command", () => {
"--no-install",
"--no-typescript",
]);
expect(output.trim()).toBe(
errorBoundaryWarning +
"\n" +
formMethodWarning +
"\n" +
metaWarning +
"\n" +
headersWarning +
"\n" +
serverModuleFormatWarning +
"\n" +
flatRoutesWarning +
"\n\n" +
getOptOutOfInstallMessage() +
expect(output.trim()).toContain(
getOptOutOfInstallMessage() +
"\n\n" +
getSuccessMessage(path.join("<TEMP_DIR>", "template-to-js"))
);
Expand Down
8 changes: 1 addition & 7 deletions packages/remix-dev/__tests__/readConfig-test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import path from "path";

import type { RemixConfig } from "../config";
import { serverBuildTargetWarning, readConfig } from "../config";
import { readConfig } from "../config";

const remixRoot = path.resolve(__dirname, "./fixtures/stack");

describe("readConfig", () => {
let config: RemixConfig;
let warnStub;
beforeEach(async () => {
let consoleWarn = console.warn;
warnStub = jest.fn();
console.warn = warnStub;
config = await readConfig(remixRoot);
console.warn = consoleWarn;
});

it("generates a config", async () => {
expect(warnStub).toHaveBeenCalledWith(serverBuildTargetWarning);
expect(config).toMatchInlineSnapshot(
{
rootDirectory: expect.any(String),
Expand Down

0 comments on commit e9d1b47

Please sign in to comment.