test.spec.ts 3.4 KB
Newer Older
D
DCloud_LXH 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
const {
  stacktracey,
  uniStracktraceyPreset,
  utsStracktraceyPreset,
} = require('../dist/uni-stacktracey.cjs.js')

const utsErrorMsg = `Appid: __UNI__E070870
e: DCloud-UTSPlugin/android/src/io/dcloud/uniplugin/TestComponent.kt: (68, 9): Unresolved reference: hello
e: DCloud-UTSPlugin/android/src/io/dcloud/uniplugin/TestModule.kt: (30, 9): Unresolved reference: hello

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':nativeplugins:DCloud-UTSPlugin:compileReleaseKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s`

D
DCloud_LXH 已提交
24 25 26 27 28 29 30 31 32
const uniErrorMsg = `Error: Sentry Error
at a.throwError(/static/js/pages-index-index.3ab0d0e5.js:1:567)
at click(/static/js/pages-index-index.3ab0d0e5.js:1:2745)
at ee(/static/js/chunk-vendors.75525bd5.js:34:11927)
at n(/static/js/chunk-vendors.75525bd5.js:34:13747)
at ee(/static/js/chunk-vendors.75525bd5.js:34:11927)
at HTMLElement.n(/static/js/chunk-vendors.75525bd5.js:34:13824)
at HTMLElement.o._wrapper(/static/js/chunk-vendors.75525bd5.js:34:53966)
at HTMLElement.i(/static/js/chunk-vendors.75525bd5.js:7:609894)`
D
DCloud_LXH 已提交
33 34

describe('uni-stacktracey', () => {
D
DCloud_LXH 已提交
35
  test('uniStracktraceyPreset local', () => {
D
DCloud_LXH 已提交
36 37
    stacktracey(uniErrorMsg, {
      preset: uniStracktraceyPreset({
D
DCloud_LXH 已提交
38
        base: 'D:/DCloud_local_git/uni-app-next/packages/uni-stacktracey/test',
D
DCloud_LXH 已提交
39 40
        platform: 'h5',
        version: '1.0.0',
D
DCloud_LXH 已提交
41
        appId: '__UNI__APPID__',
D
DCloud_LXH 已提交
42 43
      }),
    }).then((res: string) => {
D
DCloud_LXH 已提交
44 45 46 47 48 49 50 51 52
      expect(res).toEqual(`Error: Sentry Error
at   src/pages/index/index.vue:44                                                            
at   src/pages/index/index.vue?be58:12                                                       
at   node_modules/@dcloudio/vue-cli-plugin-uni/packages/h5-vue/dist/vue.runtime.esm.js:1864  
at   node_modules/@dcloudio/vue-cli-plugin-uni/packages/h5-vue/dist/vue.runtime.esm.js:2189  
at   node_modules/@dcloudio/vue-cli-plugin-uni/packages/h5-vue/dist/vue.runtime.esm.js:1864  
at   node_modules/@dcloudio/vue-cli-plugin-uni/packages/h5-vue/dist/vue.runtime.esm.js:2185  
at   node_modules/@dcloudio/vue-cli-plugin-uni/packages/h5-vue/dist/vue.runtime.esm.js:7076  
at   node_modules/@sentry/browser/esm/helpers.js:74                                          `)
D
DCloud_LXH 已提交
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
    })
  })

  test('uniStracktraceyPreset', () => {
    stacktracey(utsErrorMsg, {
      preset: utsStracktraceyPreset({
        base: '/usr/fxy/poroject/test/.sourcemap/src/',
        sourceRoot:
          '/wgtRoot/__UNI__E070870/nativeplugins/DCloud-UTSPlugin/android/src/',
      }),
    }).then((res: string) => {
      expect(res).toEqual(`Appid: __UNI__E070870
e: DCloud-UTSPlugin/android/src/io/dcloud/uniplugin/TestComponent.kt: (68, 9): Unresolved reference: hello
e: DCloud-UTSPlugin/android/src/io/dcloud/uniplugin/TestModule.kt: (30, 9): Unresolved reference: hello

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':nativeplugins:DCloud-UTSPlugin:compileReleaseKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s`)
    })
  })
})