@rpcbase/test 0.250.0 → 0.251.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/test",
3
- "version": "0.250.0",
3
+ "version": "0.251.0",
4
4
  "type": "module",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
@@ -1,4 +1,6 @@
1
1
  import fs from "fs"
2
+ import path from "path"
3
+ import { fileURLToPath } from "url"
2
4
  import { cpus } from "os"
3
5
 
4
6
  import _ from "lodash"
@@ -9,6 +11,18 @@ function mergeConfig(base, override) {
9
11
  return _.merge({}, base, override)
10
12
  }
11
13
 
14
+ function getCallerConfigDir() {
15
+ const stack = new Error().stack?.split("\n") ?? []
16
+ const frame = stack.find(line =>
17
+ line.includes("playwright.config") &&
18
+ !line.includes("defineConfig.js")
19
+ )
20
+ if (!frame) return null
21
+ const match = frame.match(/(file:[^):]+|\/[^):]+):\d+:\d+/)
22
+ if (!match) return null
23
+ return path.dirname(fileURLToPath(match[1]))
24
+ }
25
+
12
26
  const hasPassedAllPreviousTests = (data) => {
13
27
  function checkSuite(suite) {
14
28
  if (suite.specs && suite.specs.length > 0) {
@@ -68,6 +82,12 @@ const isHeadless = () => {
68
82
 
69
83
  // https://playwright.dev/docs/test-configuration
70
84
  export default function(config) {
85
+ const expected = getCallerConfigDir()
86
+ if (expected && process.cwd() !== expected) {
87
+ throw new Error(
88
+ `Playwright must be run from ${expected}. Current cwd: ${process.cwd()}.`
89
+ )
90
+ }
71
91
 
72
92
  const baseConfig = {
73
93
  globalSetup: ["./spec/helpers/globalSetup.ts"],