Skip to content

Commit

Permalink
Allow having pageName.test.tsx inside pages (#850)
Browse files Browse the repository at this point in the history
  • Loading branch information
flybayer committed Aug 12, 2020
1 parent ade63c5 commit 90a7624
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/server/src/stages/pages/index.ts
Expand Up @@ -5,7 +5,7 @@ import {handleErrors, DuplicatePathError} from "./errors"
import flow from "lodash/flow"

export function pagesPathTransformer(path: string) {
const regex = /(?:[\\/]?app[\\/].*?[\\/]?)(pages[\\/].+\.m?[tj]sx?)$/
const regex = /(?:[\\/]?app[\\/].*?[\\/]?)(pages[\\/].+(?<!test)\.m?[tj]sx?)$/
return (regex.exec(path) || [])[1] || path
}

Expand Down
Expand Up @@ -38,6 +38,11 @@ describe("createPagesPathTransformer", () => {
input: normalize("app/users/pages/one/two/three.scss"),
expected: normalize("app/users/pages/one/two/three.scss"),
},
{
name: "Ignores test pages: tsx",
input: normalize("app/users/pages/one/two/three.test.tsx"),
expected: normalize("app/users/pages/one/two/three.test.tsx"),
},
{
name: "handles leading /",
input: normalize("/app/users/pages/one/two/three.tsx"),
Expand Down

0 comments on commit 90a7624

Please sign in to comment.