0.5.0 • Published 11 months ago

swc-plugin-power-assert v0.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

swc-plugin-power-assert

SWC plugin for power-assert: Provides descriptive assertion messages through standard assert interface. No API is the best API.

power-assert

License

test at examples/bowling.test.mjs:97:5
āœ– real example (7.283209ms)
  AssertionError [ERR_ASSERTION]:

  assert(scoreOf(rollsOf(frames)) === 132)
         |       |       |        |   |
         |       |       |        |   132
         |       |       |        false
         |       |       [[1,4],[4,5],[6,4],[5,5],[10],[0,1],[7,3],[6,4],[10],[2,8,6]]
         |       [1,4,4,5,6,4,5,5,10,0,1,7,3,6,4,10,2,8,6]
         133

  133 === 132

      at TestContext.<anonymous> (/path/to/bowling.test.mjs:110:7)
      at Test.runInAsyncScope (node:async_hooks:206:9)
      at Test.run (node:internal/test_runner/test:824:25)
      at Suite.processPendingSubtests (node:internal/test_runner/test:533:18)
      at Test.postRun (node:internal/test_runner/test:923:19)
      at Test.run (node:internal/test_runner/test:866:12)
      at async Promise.all (index 0)
      at async Suite.run (node:internal/test_runner/test:1183:7)
      at async Promise.all (index 0)
      at async Suite.run (node:internal/test_runner/test:1183:7) {
    generatedMessage: false,
    code: 'ERR_ASSERTION',
    actual: 133,
    expected: 132,
    operator: '==='
  }

INSTALL

$ npm install --save-dev swc-plugin-power-assert

USAGE

via @swc/core module

const transpiled = await swc.transformFile(inputFilepath, {
  sourceMaps: true,
  isModule: true,
  swcrc: false,
  jsc: {
    parser: {
      syntax: 'ecmascript'
    },
    transform: {},
    target: 'es2022',
    experimental: {
      plugins: [
        ['swc-plugin-power-assert', {}]
      ]
    }
  }
});

via .swcrc file

{
  "jsc": {
    "parser": {
      "syntax": "ecmascript"
    },
    "experimental": {
      "plugins": [
        ["swc-plugin-power-assert", {}]
      ]
    }
  },
  "sourceMaps": true,
  "inlineSourcesContent": true
}

AUTHOR

LICENSE

Licensed under the MIT license.

0.3.0

1 year ago

0.5.0

11 months ago

0.4.1

1 year ago

0.4.0

1 year ago

0.4.2

1 year ago

0.2.0

1 year ago

0.1.1

2 years ago

0.1.0

2 years ago