Skip to content

Commit

Permalink
fix build issues and add lifecycle methods
Browse files Browse the repository at this point in the history
  • Loading branch information
m2rads committed Nov 29, 2024
1 parent b4141da commit f5e6f08
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/shortest/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ declare global {
const define: (name: string, fn: () => void | Promise<void>) => void;
const expect: Expect;
const __shortest__: ShortestGlobals;
const beforeAll: (fn: () => void | Promise<void>) => void;
const afterAll: (fn: () => void | Promise<void>) => void;
}

// Export module types
Expand Down
2 changes: 1 addition & 1 deletion packages/shortest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"prepare": "pnpm build",
"prepublishOnly": "pnpm build && chmod +x dist/cli/bin.js",
"postprepare": "node ./dist/cli/setup.js",
"build:types": "tsc --emitDeclarationOnly --outDir dist/types && cp index.d.ts dist/ && cp src/types/*.d.ts dist/types/",
"build:types": "tsc --emitDeclarationOnly --outDir dist/types && cp index.d.ts dist/",
"build:js": "esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/index.js --external:esbuild --external:punycode --external:playwright --external:@anthropic-ai/sdk --external:expect --external:dotenv",
"build:cjs": "esbuild src/index.ts --bundle --platform=node --format=cjs --outfile=dist/index.cjs --external:esbuild --external:punycode --external:playwright --external:@anthropic-ai/sdk --external:expect --external:dotenv",
"build:cli": "esbuild src/cli/bin.ts src/cli/setup.ts --bundle --platform=node --format=esm --outdir=dist/cli --metafile=dist/meta-cli.json --external:fsevents --external:chokidar --external:glob --external:esbuild --external:events --external:path --external:fs --external:util --external:stream --external:os --external:assert --external:url --external:playwright --external:@anthropic-ai/sdk --external:expect --external:dotenv --external:otplib --external:picocolors --external:punycode",
Expand Down
10 changes: 10 additions & 0 deletions packages/shortest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ declare const global: {
__shortest__: any;
define: any;
expect: any;
beforeAll: (fn: () => void | Promise<void>) => void;
afterAll: (fn: () => void | Promise<void>) => void;
} & typeof globalThis;

if (!global.__shortest__) {
Expand All @@ -29,6 +31,12 @@ if (!global.__shortest__) {
});
},
expect: jestExpect,
beforeAll: (fn: () => void | Promise<void>) => {
global.__shortest__.registry.beforeAllFns.push(fn);
},
afterAll: (fn: () => void | Promise<void>) => {
global.__shortest__.registry.afterAllFns.push(fn);
},
registry: {
suites: new Map<string, UITestBuilderInterface[]>(),
currentSuite: null,
Expand All @@ -40,6 +48,8 @@ if (!global.__shortest__) {
// Attach to global scope
global.define = global.__shortest__.define;
global.expect = global.__shortest__.expect;
global.beforeAll = global.__shortest__.beforeAll;
global.afterAll = global.__shortest__.afterAll;

dotenv.config({ path: join(process.cwd(), '.env') });
dotenv.config({ path: join(process.cwd(), '.env.local') });
Expand Down

0 comments on commit f5e6f08

Please sign in to comment.