Skip to content

Conversation

@cowboyd
Copy link
Member

@cowboyd cowboyd commented Feb 16, 2023

Motivation

Since we'll be writing more and more of PlatformScript in PlatformScript, we need a way to test PlatformScript in PlatformScript.

Approach

This adds a pls test command that will find all files ending in the .test.yaml extension in the test directory, and runs them as PlatformScript tests.

Added to stdlib is the "testing.yaml" module where you can find a test constructor, as well as matchers. The structure of a test is really, really simple for now. It is just a list of expectations:

$test:
  - expect:
    - subject
    - matcher
    - matcher
    - matcher
  - expect:
    - subject
    - matcher
    - matcher

Matchers are just functions that run on the subject and return a result for it. The following functions are shipped initially to create matchers:

  • toEqual: expected: takes an expected value and returns a matcher that passes when the subject is equal to the expected.
  • not: matcher: takes another matcher and passes only if that matcher fails.

This is not the end all be all of testing frameworks, but what it is, is something that we can use to write tests for our PlatformScript as we begin to use it.

Screenshots

2023-02-15 17 52 53

Since we'll be writing more and more of PlatformScript in
PlatformScript, we need a way to test PlatformScript in
PlatformScript.

This adds a `pls test` command that will find all files ending in the
`.test.yaml` extension in the `test` directory, and runs them as
PlatformScript tests.

Added to stdlib is the "testing.yaml" module where you can find a test
constructor, as well as matchers. The structure of a test is really,
really simple for now. It is just a list of expectations:

```yaml
$test:
  - expect:
    - subject
    - matcher
    - matcher
    - matcher
  - expect:
    - subject
    - matcher
    - matcher
```

Matchers are just functions that run on the subject and return a
result for it. The following functions are shipped initially to create
matchers:

- `toEqual: expected`: takes an expected value and returns a matcher
that passes when the subject is equal to the expected.
- `not: matcher`: takes another matcher and passes only if that
matcher fails.

This is not the end all be all of testing frameworks, but what it
_is_, is something that we can use to write tests for our
PlatformScript as we begin to use it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants