1.4.0 • Published 12 months ago

probs v1.4.0

Weekly downloads
-
License
MIT
Repository
-
Last release
12 months ago

probs

wip testing framework

Features

Custom Globals

Probs lets you set your own globals or overwrite the included ones. To do this, we use setupFile. Since each file runs in a separate worker, there's no risk of polluting the globals or prototypes of other test files.

// probs.config.js

export default {
  setupFile: async (id) => {
    // we're only providing a browser for files that match test/e2e/**
    if (id.match('test/e2e/')) {
      global.browser = await chromium.launch()
    }
  },
}

Custom Context

Each test provides context to its callback. We can set the scope by adding a context to our config. The context function will serve as middleware for the existing scope.

// probs.config.js

export default {
  context: (ctx) => {
    ctx.scopeString = ctx.scope.join(' > ')
    return ctx
  },
}
// test/file.test.js

test('can access context', (test, { scopeString }) => {
  assert.equal(scopeString, 'test/file.test.js > can access context')
})

Worker configuration

Each test runs inside its own worker. To configure a worker, we can add worker to the config.

// probs.config.js

export default {
  worker: (ctx) => ({
    env: { environment: 'test' },
    execArgv: ['--experimental-loader', 'svelte-esm-loader', '--no-warnings'],
  }),
}

For a full list of options, please refer to https://nodejs.org/api/worker_threads.html#new-workerfilename-options

How it Works

Each test file gets a dedicated worker which runs the test file.

A worker lifecycle boils down to: 1. set globals 2. run setupFile callback 3. import testFile

1.4.0

12 months ago

1.2.0

1 year ago

1.3.3

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.1.0

2 years ago

1.1.0-19

2 years ago

1.1.0-18

2 years ago

1.1.0-17

2 years ago

1.1.0-16

2 years ago

1.1.0-20

2 years ago

1.1.0-15

2 years ago

1.1.0-14

2 years ago

1.1.0-12

2 years ago

1.1.0-11

2 years ago

1.1.0-10

2 years ago

1.1.0-9

2 years ago

1.1.0-8

2 years ago

1.1.0-7

2 years ago

1.1.0-6

2 years ago

1.1.0-5

2 years ago

1.1.0-4

2 years ago

1.1.0-3

2 years ago

1.1.0-2

2 years ago

1.1.0-1

2 years ago

1.1.0-0

2 years ago

1.0.0-4

2 years ago

1.0.0-1

2 years ago

1.0.0-0

2 years ago

1.0.0-3

2 years ago

1.0.0-2

2 years ago

0.1.7

2 years ago

0.1.4

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.0.2

3 years ago

0.0.1

3 years ago