index.vue 1.3 KB
Newer Older
Y
yurj26 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
<template>
    <view class="content">
        <view v-for="(item,name) in result" :key="name" class="result">
            <view>{{name}}测试结果:</view>
             <view>
                测试api:{{item.passed.join(', ')}}
            </view>
            <view>总共:{{item.total}}</view>
            <view>通过:{{item.passed.length}}</view>
            <view>失败:{{item.failed.length}}</view>
            <view v-for="(fail,index) in item.failed" :key="index" class="failed">
                <view>{{fail.split('\n')[0]}}</view>
                <view>{{fail.split('\n')[1]}}</view>
            </view>
        </view>
    </view>
</template>
<script>
    import {
        runTests
    } from '../../uni_modules/uts-tests'
    export default {
        data() {
            return {
                result: {}
            }
        },
        onReady() {
            this.test()
        },
        methods: {
            test() {
                this.result = runTests()
                console.log(this.result)
            }
        }
    }
</script>
<style>
    .content {
        padding: 32rpx;
    }

    .passed {
        color: green;
    }

    .failed {
        color: red;
    }
    .result {
        margin-bottom: 20rpx;
    }
</style>